GCSE · 9 exercises
Python input and output
input() waits for one line typed by the user and gives it back as text. Keep it in a variable to use it later.
Each call reads one line, so a program that needs two answers calls input() twice.
name = input()
town = input()
print(f"{name} lives in {town}.")Watch for: Don't put a question inside input("...") here: the prompt is printed too, and the tests compare everything printed.
Exercises
- Hello, nameRead a name and greet that person.Novice
- Echo, echoRead a word and print it twice, each time on its own line.Novice
- Full nameRead a first name and a last name and print the full name.Novice
- Age next yearRead someone's age and say how old they will be next year.Novice
- Backwards orderRead three lines and print them in the opposite order.Novice
- Swap two valuesRead two lines, a and b, and print them swapped: b first, then a.Novice
- A tiny storyRead an animal and a verb, and print a sentence with them.Novice
- Favourite foodRead a name and a food, and say who likes what.Novice
- InitialsRead a first and a last name and print the initials, each followed by a dot.Novice