Inputting Numbers

Inputting Numbers

With the input command, Python automatically assumes the user will enter a string (alphanumeric characters) but if you want to enter whole numbers then you need the int command. int stands for integer (a whole number) and goes before inputdon’t forget the double closing brackets.

Screenshot 2016-08-30 at 10.00.18 AM

Screenshot 2016-08-30 at 10.03.44 AM

Using float instead of int allows a decimal number to be entered instead. Also don’t forget the double closing brackets!

Screenshot 2016-08-30 at 10.01.37 AMScreenshot 2016-08-30 at 10.02.19 AM

Practice Task 1

Inputting not working? Tick off these common errors:

Variable name written correctly?
Correct input line?
Used int for a whole number?
Double brackets for int / float?
Have you used a comma between different sections?

< Back to Section Two