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?"))

Answer :

Cytokine

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.

Other Questions