PCEP Data Types, Variables, Basic I/O and Operators • Set 13
PCEP Data Types, Variables, Basic I/O and Operators Practice Test 13 — 15 questions with explanations. Free, no signup.
A company runs a script that processes user input temperatures. The script expects integers but sometimes users enter floats. The current code is: temp = int(input("Enter temperature: ")). When a user enters "36.5", the script crashes with a ValueError. The developer needs to modify the script to handle both integer and float inputs gracefully, converting the input to an integer (by truncation) for processing. Which of the following is the best course of action?
Choose an answer to begin — your selection is scored in the full session.
15 questions · instant feedback and full explanations after every question.