GCSE Python #6: User Input

Опубликовано: 10 Октябрь 2024
на канале: MrBrownCS
4,922
47

Looking at the built-in Python function for taking user input coming from their keyboard. Its use, including the often necessary casting, are also demonstrated.

Try Now Answers:
1. String – if we want to use it as a number, we’d need to cast it to either a float or integer

2. E.g.
name = input("What's your name? ")
print("Hello",name+"!")

3. E.g.
ageInYears = int(input("How old are you? "))
ageInSeconds = ageInYears * 365 * 24 * 60 * 60
print("You have been alive for",ageInSeconds,"seconds")

Any questions/ feedback/ enquiries: [email protected]