Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Python programming for KS3

Similar presentations


Presentation on theme: "Introduction to Python programming for KS3"— Presentation transcript:

1

2 Introduction to Python programming for KS3

3 Learning Objectives: We’re learning to develop our understanding of python programming through the following techniques: Syntax Errors Variable names Comments

4 Making a sandwich: You may remember that programming is sequential….
Eat the sandwich Close the sandwich Sprinkle the cheese Put the two slides of bread on a plate Grate the cheese Cut the sandwich Spread the butter You may remember that programming is sequential…. Put these in the correct order, your teacher may get you to make the sandwich If you want to, you can get your students to make the sandwich using bread and cheese, you could buy pre-grated cheese and let them eat the sandwiches afterwards. Demonstrate the point of programming being carried out in a sequence. Demonstrate the importance of putting things in the correct order. If they’re not in the correct order, you have a logic error. Correct order: 1- Put the two slices of bread on a plate 2 – Spread the margarine / butter 3 – Grate the cheese 4 – Sprinkle the cheese on the bread 5 – Close the sandwich 6 – Cut the sandwich 7 – Eat the sandwich

5 Logical Errors: 1- Put the two slices of bread on a plate 2 – Spread the margarine / butter 3 – Grate the cheese 4 – Sprinkle the cheese on the bread 5 – Close the sandwich 6 – Cut the sandwich 7 – Eat the sandwich Remember that programs should be put in the correct order. If they’re not in the correct order, we can have something called a logic error. Talk to your students about possible errors that will have occurred. Why do they happen? What do you think would happen if this was a real life piece of code?

6 What is a program? Open up python IDE and type in the following:
Print (“hello world”) What happens, when you press enter?

7 What is a program? Open up python IDE and type in the following:
Print (“hello world”) What happens, when you press enter?

8 What is a program? Open up python IDE and type in the following: 5 + 9
What happens, when you press enter?

9 What is a program? Open up python IDE and type in the following: 5 + 9
What happens, when you press enter?

10 Syntax Errors Within python, there are a number of operators and functions which are built into the language. You’ve just seen how it can handle number, do any other operators work? How do we subtract, divide or multiply. You give it a try! Try printing other phrases, do they work? Extension: - Now type out: print (hello world) What happens?

11 Syntax Errors Extension: - Now type out: print (hello world)
What happens? SYNTAX ERROR Like with English, programming languages have their own check similar to a grammar check. When you run code it checks to see whether it is in the form for the computer to compute. If you do not do this the computer throws out an error like above.

12 Using Variables Variables are like a bucket, they’re used to store a number, data, text or image. You can empty it or refill it as many times as you like. For example, to create a variable in python we might do the following: Studentname = (“James”) This now means that the word James is stored in student name. You can even print it to the screen by doing. Print (Studentname).

13 Using Variables You can do the same with numbers, for example:
Print (Number3)

14 Combine variables You can do the same with numbers, for example:
Using number3 you can combine your sentence with the text you stored in your variable. You could do the same with names or other values. Notice the Comma separating it.

15 Using Variables / Syntax
Independent Task Using what you have learnt see if you can print screen and evidence the following for your teacher. You should evidence this by taking screen shots. Show a syntax error and annotate it to explain it. Show how to print text or numbers. Show how to carry out calculations with numbers. Show use of variables through either calculation or text. See if you can make a sentence with the use of two variables. Extension Leading into next weeks lesson, you will have to know about different types of variables and data types. See if you can research the types available and examples of their use. You could really extend yourself by trying some of the code…


Download ppt "Introduction to Python programming for KS3"

Similar presentations


Ads by Google