Conditions o If statement: specify code to be executed, if a condition is true o Conditions allow for various possible paths in a program o Conditions are either True or False 3 < 5 4 > 7 x == 10 x > 10 (2 * x) > 20 if condition: perform task
User input o Programs interact with the user ▪ Buttons, Passwords, Mouse clicks o Take information provided by the user to create a custom output. o Conditions (if statements) are a common application of user input, since we can create programs that provide output based on what is true or false about the input. Sample program – User input and conditions col = input(“What colour snowflake should I make?”) if col == “blue”: snowflake(“blue”) if col == “red”: snowflake(“red”)
Lesson
Create shapes and define their code within user-defined functions. Produce varying outputs (i.e. different sizes and colours) by passing in different values as parameters.
Utilize conditions (if statements) and user input to create shapes based on the information provided by the user.