CHALLENGES
It's time to put what you've learned in the workshop to the test!
Challenge 1: String Formatting
You'll have 2 minutes to write a program that does the following:
Using string formatting, write a program that outputs a string with your name and age to the console, e.g.:
"Hi! My name is Rob and I'm 19 years old."
You MUST use variables to store the values of your name and age.
Solutions will be handed out to all participants at the end of the session.
Challenge 2: Conditional Statements
You'll have 10 minutes to write a program that does the following:
Gives the user an option to pick between three flavours of ice cream.
If the user doesn't select anything, the program will select a different flavour.
Outputs which flavour the user selected as a string, for example:
"You chose chocolate flavoured ice cream."
The ==
operator can be used to check equivalence of values!
Extension
Let the user select more than one flavour of ice cream, by entering a string such as
"1 & 3"
or"2 & 1"
.Parse the inputted string, extracting the two numbers, and output a sentence informing the user of their flavour selections, for example:
"You chose chocolate and strawberry flavoured ice cream."
You can use the .split() function to split the string into a list at the '&' symbol.
Solutions will be handed out to all participants at the end of the session.
Challenge 3: Using Libraries
You'll have the remaining time in the workshop to write a program that does the following:
Gives the user an option to pick between drawing three shapes, e.g. a triangle, square and circle.
Draw the selected shape.
If the user doesn't select anything, the program will draw a straight line.
To draw a perfect circle easily, there's a single function that does it for you! Try and find it in the Turtle documentation linked in the Resources section.
Extension
Give the user another option to draw the first letter of your name!
Last updated