Programming In Lesson 4.

Slides:



Advertisements
Similar presentations
Making Decisions in Python Sec 9-10 Web Design. Objectives The student will: Understand how to make a decision in Python Understand the structure of an.
Advertisements

Programming in python Lesson 2.
Running JavaScript Chapter 18.
PROGRAMMING In Lesson 5. RECAP  Complete the starter activity.
Python Programming Using Variables and input. Objectives We’re learning to make use of if statements to enable code to ask questions. Outcomes Build an.
Python Programming Introduction to programming using python.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Do it now activity Last term we learnt about how data is represented in a computer and about how to identify different volumes of data. How many bits in.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
Lesson Topic: True and False Number Sentences Lesson Objective: I can…  Explain what the equality and inequality symbols include. They will determine.
PROGRAMMING In Lesson 2. STARTER ACTIVITY Complete the starter activity in your python folder – lesson 2 Now we will see how you got on and update your.
Python Programming Using Variables and input. Objectives We’re learning to use basic knowledge of variables combined with user input. Outcomes Continue.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X1 Chapter 3 Control Statements.
PROGRAMMING In. Objectives  We’re learning to develop basic code with the use of the correct syntax and variables. Outcomes  Explain what syntax is.
22/11/ Selection If selection construct.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
31/01/ Selection If selection construct.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
3.1.3 Program Flow control Structured programming – SELECTION in greater detail.
Python Lesson 2.
Learning Objective To be able to… Understand flow chart symbols Complete and correct flow chart algorithms Create a program based on a flow chart.
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
CSE202: Lecture 5The Ohio State University1 Selection Structures.
PROGRAMMING In Lesson 6. RECAP  Discuss with the person next to you...  what you have enjoyed about python programming  What you have found difficult.
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
KEY STAGE 3 ICT Databases – Lesson 2. Recap of keywords – Task 2A In your workbooks from last lesson What is a database? A DATABASE is a collection of.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
PYTHON PROGRAMMING Year 9. Objective and Outcome Teaching Objective Today we will look at conditional statements in order to understand how programs can.
Starter What does the following code do?
Introduction to Decision Structures and Boolean Variables
Introduction to Programming
Whatcha doin'? Aims: To start using Python. To understand loops.
Chapter 4 The If…Then Statement
Lesson 4 - Challenges.
Introduction to Programming
Starter Write a program that asks the user if it is raining today.
Lesson 1 Learning Objectives
Number Line Where are you on the learning journey?
Selection CIS 40 – Introduction to Programming in Python
Introduction to Programming
Programming In Lesson 3.
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Learning Outcomes –Lesson 4
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
1.6 Solve Linear Inequalities
If selection construct
Introduction to Programming
Design and Implementation
If selection construct
Fractions Pages 8 – 59.
Python 21 Mr. Husch.
Chapter 5: Control Structure
Computer Science Core Concepts
Programming - Buttons Intro to Robotics.
Operations Python code.
Programming - Buttons Intro to Robotics.
JavaScript.
PYTHON: BUILDING BLOCKS Sequencing & Selection
An Introduction to Linux
CS2011 Introduction to Programming I Selections (I)
Beginning Python Programming
Understanding Code Workshop 2.
Programming In.
Introduction to Programming
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Hardware is… Software is…
Presentation transcript:

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.

Operators Operator What it means Typed in IDLE Displayed + Add to >>> 4 + 5 >>> 9 - Subtract >>> 5 - 1 >>> 4 * Multiply >>> 7 * 3 >>> 21 / Divide >>> 7 / 4 >>> 1.75 // Whole number division >>> 20 // 3 >>> 6 % Remainder after whole number division >>> 20 % 3 >>> 2 ** To the power of >>> 3 ** 4 >>> 81

Condition Operators Operator What it means Example Displayed == Equals >>> 5 == 4 >>> False != Not equals to >>> 5 != 4 >>> True > Greater than >>> 5 > 4 < Less than >>> 5 < 4 >= Greater than or equals to >>> 5 >= 5 <= Less than or equals to >>> 4 <= 4

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 Teacher to explain each line 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 Explanation that the print after the else is not indented and it will execute EVERY time the function is called irrespective of the user_input value. Try this? What happens now with the IF statement Block

Indenting Try this? What happens now with the IF statement Block Explanation that the print after the else is not indented and it generate an error message as there is no statement after the IF block 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 a = get_user_boolean_input () Write a program to: Use the get_user_input_boolean function 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 will need this program later so save it as Truth_Table_And

The solution

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