160 likes | 256 Views
Programming. In. Lesson 4. R ecap. Complete the starter activity. Objectives. Understand a branching statement (if .. then .. else) Understand about indenting and blocks of statements Able to use a function to create a truth table Outcomes
E N D
Programming In Lesson 4
Recap • Complete the starter activity
Objectives • Understand a branching statement (if .. then .. else) • Understand about indenting and blocks of statements • Able to use a function to create a truth table Outcomes • All-Level 4 written code using if..then..else - with help written a truth table in code • Most-Level 5 Be able to write a these with little help. • Some-Level 6 Independently write these and adapt them and complete one of the extension tasks.
The If Statement • The basic if statement is this. • If statements are one of the building blocks of programming.
If statements • Copy this on the board. – save it in lesson 4 as my_if • Run the program
If…ELSE … statements Add these 2 lines Copy this on the board. – save it in lesson 4 as my_else Student to explain?
Indenting Try this? What happens now with the IF statement Block
Indenting Try this? What happens now with the IF statement Block
Boolean Operators aka TRUTH TABLES • I could tell you about these….but you would probably forget. • Lets write a python program to teach you. • Remember Boolean variables can be either True or False. What happens when we get 2 together such as • >>> a = True • >>> b = False • What is the result for a AND b? • Back to our program.
The truth tables • Write a program to: • Use the get_user_input_booleanfunction in lesson 4 folder to help you. • Open the function and use it in your program such as a = get_user_boolean_input () This asks the user to enter either True or False • Display the value of variable a and variable b • Display the result of a and b (the operator AND) • You willneed this program later so save it as Truth_Table_And
Truth Table Or • Write another program to display the result of a or b • Save it as Truth_Table_Or • Amend this program so that it asks the user which table they want to use
Plenary • Try the plenary quiz in my documents -> python -> folder 4
Fun Time • Open the Turtle_intro python program and read the comments. • Just have fun or…. • Try to create …. • A blue box • With a green circle in it • With your initials on top of the box. • An easter egg….