1 / 16

Programming

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

guido
Télécharger la présentation

Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming In Lesson 4

  2. Recap • Complete the starter activity

  3. 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.

  4. Operators

  5. Condition Operators

  6. The If Statement • The basic if statement is this. • If statements are one of the building blocks of programming.

  7. If statements • Copy this on the board. – save it in lesson 4 as my_if • Run the program

  8. If…ELSE … statements Add these 2 lines Copy this on the board. – save it in lesson 4 as my_else Student to explain?

  9. Indenting Try this? What happens now with the IF statement Block

  10. Indenting Try this? What happens now with the IF statement Block

  11. 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.

  12. 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

  13. The solution

  14. 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

  15. Plenary • Try the plenary quiz in my documents -> python -> folder 4

  16. 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….

More Related