nerdexam
Python_Institute

PCEP-30-02 · Question #267

You are an intern for ABC electric cars company. You must create a function that calculates the average velocity of their vehicles on a 1320 foot (1/4 mile) track. Consider the following code…

The correct answer is B. 1 | oat. Option B is correct because both ??? should be float (shown as oat due to a formatting artifact where fl was dropped). Since input() always returns a string, a conversion function is needed - and float is the right choice here because the problem demands maximum precision, and…

Question

You are an intern for ABC electric cars company. You must create a function that calculates the average velocity of their vehicles on a 1320 foot (1/4 mile) track. Consider the following code.
distance = ???(input('Enter the distance travelled in feet'))
distance_miles = distance/5280 # convert to miles

time = ???(input('Enter the time elapsed in seconds'))
time_hours = time/3600 # convert to hours

velocity = distance_miles/time_hours
print('The average Velocity : ', velocity, 'miles/hour')
The output must be as precise as possible. What would you insert instead of ??? and ??? ?

Options

  • A1 | int
  • B1 | oat
  • C2 | oat
  • D2 | int

How the community answered

(49 responses)
  • A
    2% (1)
  • B
    84% (41)
  • C
    4% (2)
  • D
    10% (5)

Explanation

Option B is correct because both ??? should be float (shown as oat due to a formatting artifact where fl was dropped). Since input() always returns a string, a conversion function is needed - and float is the right choice here because the problem demands maximum precision, and dividing integers can produce truncated results in some contexts while float preserves decimal accuracy throughout the calculation.

Option A (int) fails because converting the input to an integer truncates any decimal portion - entering 1320.5 feet would be treated as 1320, silently losing precision and contradicting the requirement for the most precise output. Options C and D appear to reference float and int respectively with a label of 2 instead of the correct 1, likely pointing to wrong answer groupings; neither represents a valid Python function named 2. The core issue with int in any form (A or D) is that time measurements like 9.87 seconds would be rounded to 9, significantly altering the calculated velocity.

Memory tip: When a problem says "as precise as possible," always reach for float - think of it as floating decimal point for fine precision, while int is integer for imprecise whole numbers only.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice