Presentation is loading. Please wait.

Presentation is loading. Please wait.

Python Programming Using Variables and input. Objectives We’re learning to use basic knowledge of variables combined with user input. Outcomes Continue.

Similar presentations


Presentation on theme: "Python Programming Using Variables and input. Objectives We’re learning to use basic knowledge of variables combined with user input. Outcomes Continue."— Presentation transcript:

1 Python Programming Using Variables and input

2 Objectives We’re learning to use basic knowledge of variables combined with user input. Outcomes Continue to use variables. Make use of user input. Use basic data types.

3 What is wrong? - Starter Using your worksheet, can you spot all of the errors? There are a number of hidden errors. Print(hello) Print(This is the start of the lesson”) Print(“You need to remember what we did last week”) print(“For Example”) print(“This is how you use a variable in a sentence”) Number1 = 15 Print(“Your age is” sentence)

4 What is wrong? – Starter / Answers Using your worksheet, can you spot all of the errors? There are a number of hidden errors. Print(hello) Print(This is the start of the lesson”) Print(“You need to remember what we did last week”) print(“For Example”) print(“This is how you use a variable in a sentence”) Number1 = 15 print(“Your age is” sentence)

5 What is input? In your previous lesson, you learnt how to store variables. Sometimes, we need our program to ask us for our input. Try this? What happens? See the next slide…

6 What is input? In your previous lesson, you learnt how to store variables. You can see how the program waits for input from the user before carrying on. Adapt, this code so that it stores different variables and it asks for different input. Don’t forget to evidence your code for later use.

7 Data Types? While coding, it is important to use the correct data type. For example, you wouldn’t try to save your name in a number data type. It would not be compatible. Here are some of the data type available: –Integer –String –Float –Boolean There are many more available such as byte and list but we will not be using these just yet.

8 Strings? A string is a data type generally used for a sequence of characters. An example of a string data type is shown below: “Hello” “Goodbye” “Welcome” To input a string into your program, you use the input command. input()

9 Integers? An integer is a datatype generally used for numbers. A value stored in the datatype is usually positive or negative. Example input would be: 6 7 -250 3281. To include input from an integer, you would use the following code: int(input())

10 Floats? The best way to remember float is that it is used so that we can get a more accurate result. We tend to use float when working with decimal numbers. Examples include: 2.6 2.8 456.198 -89.76 To include input from a float, you would use the following code: float(input())

11 Boolean? When carrying out tests in life, things are usually write or wrong. There is no blurred lines in between. You either saved your work or you didn’t. Booleans are a data type which test two outcomes. True or False. Most of the programming so far has been lower case, however in Python we use ‘T’ or ‘F’ and it matters! Here is an example; isquestioncorrectvar = True

12 Example

13 Now it’s your turn? Task 1 - Open up python IDE and try to create a script which combines the use of sentences and the four different inputs you’ve just learnt about. Print off your evidence for your folder and highlight the different data types for your text. Remember to use: Integer Float String Boolean Task 2 (Extension) See if you can combine multiple data types on one line. You should create a story with the use of inputs. For example, name, age, location, monstername. Once all the inputs have been typed the story is shown including the inputs.

14 Plenary Self Assessment: Your teacher has issued you with a self assessment sheet. You will have today’s objects and outcomes on it. Task Comment on the lesson. Talk about the positive experience you have had and talk about things you need a little more help on. If you managed to get onto the extension tasks, what have you found out? Spot the Syntax and DataType Your teacher has givne you a piece of code. You must decide which data types belong in the correct place and you must link in your previous lesson and spot the syntax mistakes within the code.


Download ppt "Python Programming Using Variables and input. Objectives We’re learning to use basic knowledge of variables combined with user input. Outcomes Continue."

Similar presentations


Ads by Google