1 / 20

p rogramming in python

p rogramming in python. Lesson 2. Starter Activity. Complete the starter activity. Recap Starter. Recap starter What is wrong with it? print(“hello) number = 17 number 17 print(“Your number is”,number ) PRint (“bye”). print(“hello”). print(“bye”). Lesson Outcomes.

aine
Download Presentation

p rogramming in python

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 python Lesson 2

  2. Starter Activity Complete the starter activity

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

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

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

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

  7. Variables Assignment/Input >>> N = 17 >>> N >>> 17 Variable Result/Output

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

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

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

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

  12. Data Types • Examples of strings are: 'Hello', "Goodbye". To input a string, use input() • Examples of integers are: 2, 6, -89, 45421. To input an integer at the screen, use int(input()) • Examples of floats are: 2.4, 6.0, -89.54, 111.111. 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!

  13. 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, 45421. How do you enter it? int(input()) What is a float number How do you enter it? float(input()) What is a boolean? has the value True or False. Variableboolean = True

  14. 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, 45421. To input an integer at the screen, use int(input()) • 2.4, 6.0, -89.54, 111.111. 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!

  15. Task 3 • Your code should look something like this

  16. Self Evaluation Task • Open the Self Evaluation Task. • 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.

  17. 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()

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

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

  20. Acknowledgments • Some resources and lessons were taken from http://www.pythonsummerschool.net/

More Related