Python Institute PCEP PCEP-30-02 Question # 17 Topic 2 Discussion
PCEP-30-02 Exam Topic 2 Question 17 Discussion:
Question #: 17
Topic #: 2
Insert the code boxes in the correct positions in order to build a line of code which asks the user for a float value and assigns it to the mass variable.
One possible way to insert the code boxes in the correct positions in order to build a line of code that asks the user for a float value and assigns it to the mass variable is:
mass = float(input("Enter the mass: "))
This line of code uses the input function to prompt the user for a string value, and then uses the float function to convert that string value into a floating-point number. The result is then assigned to the variable mass.
You can find more information about the input and float functions in Python in the following references:
[Python input() Function]
[Python float() Function]
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit