G7 programing language Teacher / Shamsa Hassan Alhassouni
What we will Learn today? Combination of text and numbers Understand variables , inputs Practical tasks
9533 100 3 print(“95” + “33”) print( 50*2) Think & Share print( 15//4) Without using python program.. What will be the output of the following statements ? print(“95” + “33”) print( 50*2) print( 15//4) print( 15%4) 9533 100 3
Activity 1. Open the python edu Select ‘the existing project named (grade7-1) Click file > new > python file Give the python file a name. (math2-7-1) print (“111 divided by 4 = “ , 111/4)
Combining text and numbers Python can combine between text and numbers and , is used as separator. What will be the output of the following line: print (“11 divided by 4 also equals= “ , 11/4, “remainder “, 11%4) 11 divided by 4 also equals= 2.75 remainder 3
Its like a box used to store information (numbers or string) Variables Its like a box used to store information (numbers or string) Books How to write in Python : Declare name (no spaces allowed) Assign a value Use the variable num1 = 1 num2 = 5 print (num1 + num2) print (num2 – num1) print (num1 * num2) Super Student Shoes Task num = 1 Print (num) Accessories
Variables Task Challenge Question String We can use variables for string also String Task text1= “hello” text2= “friends” print (text1 + text2) text= “hello” print (text) Super Student a = 10 a =1 a=2 b = 2 print(a + b) one = 1 two = 2 three = one + two print(three) Challenge Question Write the output without using Python
Inputs To get input from user we use function called (input) Output is when sending back data Hello!! Hi !! How are you ladies ? Fine ..Thanks How old are you ? 12 Where do you live ? Dubai
Task name = input ("what is your name ? ") print (name) Super Student Try to code the following What is your name ? Mariam Hello mariam name = input ("what is your name ? ") print (name) Super Student year= input (“which year was you born ?") print (year) Try to code the following Which year was you born? Mariam born in 2004
Challenge P/43 Joining String We use (+) to join between string only name = input("What's your name? ") print("Nice " + name + "!") age = input("Your age? ") print("So " + age + " years old, " + name + "!") We use (+) to join between string only Challenge P/43 Book Activity – Calculate area of the room Area = Width * Height Area = W * H
Challenge 2 Challenge HW P-44 Book Activity – Calculate each person how much to pay Challenge HW P-44 Make a program TO ask “What is the total cost of the bill ? “ “ How much is the percentage of the tip ?” “How many people will share the bill ? “ Then calculate the price per each person
How easy did find the today’s lesson in python?