Practical Challenges 1

<< Previous: InputNext: Substrings >>

About the challenges

The challenges below allow you to apply your knowledge of the topics up to this point. Attempt the challenges in a Python IDE of your choice.

Challenge 1: Personal greeting

Ask the user their name and store it in a suitably named variable. Output Hello followed by the name the user enters.



name = input("Enter your name: ")
print(f"Hello {name}")

Challenge 2: Story time

Write a story that has a hero, a location it takes place, the type of pet the hero owned and a number of years ago that it happened. You should get the user to enter the hero, location, pet and number of years ago the story happened. When the story is output it should use the values entered by the user e.g. They may enter "Bob", "the Moon", "Dragon", and 1000 and the story might output "1000 years ago on the Moon there lived a brave hero called Bob who travelled around with his pet Dragon."



hero = input("Enter the hero's name: ")
place = input("Enter the place where it happened: ")
pet = input("Enter the type of pet the hero had: ")
when = input("How long ago did this story take place? ")
print(f"{when} years ago on {place} there lived a brave hero called {name} who travelled around with his pet {pet}.")
<< Previous: InputNext: Substrings >>

© All materials created by and copyright S.Goff