Solutions

Solutions to workshop challenges

Challenge 1: String Formatting

Solution

name = "Robert"
age = 19

print("Hi! My name is {} and I'm {} years old.").format(name, age)

Challenge 2: Conditional Statements

Solution without extension

print('''
Choose any of the three following ice cream flavours...
1. Chocolate
2. Strawberry
3. Vanilla

If you enter none of the above, you will be given mint.
''')

choice = int(input("Pick your choice (enter number 1-3) > "))

if (choice == 1):
    flavour = "chocolate"
elif (choice == 2):
    flavour = "strawberry"
elif (choice == 3):
    flavour = "vanilla"
else:
    flavour = "mint"

print("You chose {} flavoured ice cream.").format(flavour)

Solution with extension

Challenge 3: Using Libraries

Solution

Last updated

Was this helpful?