You want to write a program that asks the user for a value. For the rest of the program you need a whole number, even if the user enters a decimal value. What would you have to write?
A.
num = str(input('How many do you need?'))
B.
num = int(float(input('How many do you need?')))
he input() function gets the user's input as a string.
float() converts that string into a floating-point number (allowing for decimal input).
int() then converts the float to an integer, effectively discarding the decimal part.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
akumo
1 month ago