91.2k views
3 votes
WHY ISN"T IT C!?

Which line of code will only allow a non-decimal point to be stored in a variable?


a. candyCost = float(input("How much is the candy?"))

b. candyCost = input("How much is the candy?")

c. candyCost = int(input("How much is the candy?"))

d. candyCost = str(input("How much is the candy?"))

User Waggledans
by
4.1k points

2 Answers

6 votes

Answer: IT'S B

Step-by-step explanation:

User Snowmantw
by
3.5k points
4 votes

The only correct answer is C.

A allows decimal and non-decimal values.

B allows any string and you could put a decimal point value into it.

C only allows whole numbers.

D is the same as B just a bit more redundant.

User Hakkar
by
4.8k points