# Programming in python Lesson 2.

## Presentation on theme: "Programming in python Lesson 2."— Presentation transcript:

programming in python Lesson 2

Starter Activity Complete the starter activity

Recap Starter Recap starter What is wrong with it? print(“hello)
print(“hello) number = 17 number 17 print(“Your number is”,number) PRint(“bye”) print(“hello”) print(“bye”)

Lesson Outcomes All-Level 4- Know the key data types discussed in lesson With help be able to write a variable with help To be able to store a user inputted variable with help Understand and demonstrate the basic data types Most-Level 5- Be able to write a these with little help. Some-Level 6- independently write these and adapt them

Recap Lets recap what we learnt last lesson What is a program?
A program is a sequence of instructions that specifies how to perform a computation. What is syntax? Refers to the spelling and grammar of a programming language Recap starter. Possible opportunity for grading/formative/summative assessment through the sheets.

Variables One of the most powerful features of a programming language is the ability to manipulate variables. A variable is a name that refers to a value. The assignment statement creates new variables and gives them values: >>> message = "What's up, Doc?“ >>> n = 17 Demonstrate on board

Variables >>> N = 17 >>> N >>> 17
Assignment/Input >>> N = 17 >>> N >>> 17 Variable Result/Output Demonstrate this with an example in Python

Using variables to demonstrate basic math code. + - / * E.g. Number 1 + number 1 Variables If you are stuck you can download the Help program

Task 2 Have a look at this line of code print(“Your number is”,number)
number is a variable The comma separates the text and the variable Your task is to write a code that prints a name and displays it. Have a look at the starter task to help you.

input Now we know what a variable is we can use the input statement to store things. >>> print(“what is your name”) >>>name = input() >>>print(name) Copy this on the board Adapt this code to something of your choosing e.g. a user inputs their details then you display them

Data types Integer Float String Boolean
There are mean other numbers but we will stick to these main ones

Data Types Examples of strings are: 'Hello', "Goodbye". To input a string, use input() Examples of integers are: 2, 6, -89, To input an integer at the screen, use int(input()) Examples of floats are: 2.4, 6.0, , To input a float number at the screen, use float(input()) A boolean variable always has the value True or False. Remember Python is case sensitive so the capital 'T' and 'F' really matters!

Data types What is a string?
Examples of strings are: 'Hello', "Goodbye". How do you enter it? Input() What is a integer are: 2, 6, -89, int(input()) What is a float number float(input()) What is a boolean? has the value True or False. Variableboolean = True

Task 4 Have a go at entering these values and displaying them
strings are: 'Hello', "Goodbye". To input a string, use input() integers are: 2, 6, -89, To input an integer at the screen, use int(input()) 2.4, 6.0, , To input a float number at the screen, use float(input()) A boolean variable always has the value True or False. Remember Python is case sensitive so the capital 'T' and 'F' really matters!

Have a look at the outcomes of the lesson. Write down the level you think you got this lesson Self evaluate your progress this lesson and write your Level and your Student Next Step.

Plenary Now we know what a variable is we can use the input statement to store things. >>> print(“what is your name”) >>>name = _________ >>>print(name) input()

Plenary Integer _______ String
There are mean other numbers but we will stick to these main ones Float Boolean

Plenary 'Hello', "Goodbye". 2, 6, -89, 45421. float(input())
What is a string? Examples of strings are: How do you enter it? Input() What is a integer are: int(input()) What is a float number What is a boolean? has the value True or False. Variableboolean = True 'Hello', "Goodbye". 2, 6, -89, float(input())

Acknowledgments Some resources and lessons were taken from