top of page
top

## Inputting Whole Numbers in Python

To enter whole numbers then you must use the int command.

int stands for integer (a whole number) and is typed before input – don’t forget the double brackets at the end.

age = int(input("How old are you? "))
print("Have you really lived for, age , "years?")

=

How old are you? 99

Have you really lived for 99 years?

Type an input line (with int) to ask the user how many times they’ve been to the zoo.

Example solution:

How many times have you been to the zoo? 3

You've been to the zoo 3 times? I love animals!

## Inputting Decimal Numbers in Python

Using float instead of int allows a decimal number to be entered instead.

Again, don’t forget the double brackets at the end.

miles = float(input("How far have you walked today? "))
print("You really walked for, miles , "miles? Wow!")

=

How far have you walked today? 5.6

You really walked for 5.6 miles? Wow!

Type an input line (with float) to ask the user their height in metres.

â€‹