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

Slides:



Advertisements
Similar presentations
EasyGUI “Probably the Easiest GUI in the world”. Assumptions (Teachers’ Notes) This resources sets out an introduction to using easyGUI and Python
Advertisements

Programming in python Lesson 2.
Python Magic Select a Lesson: Why Learn to Code? Basic Python Syntax
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
The Scratch Calculator You are all going to be real computer programmers!!!
Noadswood Science,  To know the basics of Python coding and decoding Monday, September 07, 2015.
An Introduction to Textual Programming
Week 2 - Monday.  What did we talk about last time?  Software development  Lab 1.
Python Programming Using Variables and input. Objectives We’re learning to make use of if statements to enable code to ask questions. Outcomes Build an.
Python Programming Introduction to programming using python.
Python File Handling. In all the programs you have made so far when program is closed all the data is lost, but what if you want to keep the data to use.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Java Data Types. Primitive Data Types Java has 8 primitive data types: – char: used to store a single character eg. G – boolean: used to store true or.
Do it now activity Last term we learnt about how data is represented in a computer and about how to identify different volumes of data. How many bits in.
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
Variables and Expressions CMSC 201 Chang (rev )
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
Type accurately challenge! This is a starter activity and should take 2 minutes [ slide 1 ] 1.Can you type out the code in Code Box 2.1 with no errors.
Scratch Programming Lesson 4 Question asking and answering.
Lesson 6. Python 3.3 Objectives. In this lesson students will learn how to output data to the screen and request input from the user. Students will also.
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
PROGRAMMING In Lesson 2. STARTER ACTIVITY Complete the starter activity in your python folder – lesson 2 Now we will see how you got on and update your.
PROGRAMMING In. Objectives  We’re learning to develop basic code with the use of the correct syntax and variables. Outcomes  Explain what syntax is.
End of unit assessment Challenge 1 & 2. Course summary So far in this course you have learnt about and used: Syntax Output to screen (PRINT) Variables.
Decision Structures, String Comparison, Nested Structures
Variables and Expressions CMSC 201. Today we start Python! Two ways to use python: You can write a program, as a series of instructions in a file, and.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
NAME Python Programming Workbook Select a Lesson:
Variables and Strings. Variables  When we are writing programs, we will frequently have to remember a value for later use  We will want to give this.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
Python Lesson 2.
Algorithms and Pseudocode
GCSE Computing: Programming GCSE Programming Remembering Python.
B065: PROGRAMMING Variables 2. Starter  What is wrong with the following piece of code: Option Explicit Off Dim num1 as string Dim num2 as integer num1.
For Loop GCSE Computer Science – Python. For Loop The for loop iterates over the items in a sequence, which can be a string or a list (we will discuss.
Programming In Python. Starter Using the internet… Find what a programming language is.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #003 (February 14, 2015)
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
Learning to use a ‘For Loop’ and a ‘Variable’. Learning Objective To use a ‘For’ loop to build shapes within your program Use a variable to detect input.
Input, Output and Variables GCSE Computer Science – Python.
GCSE COMPUTER SCIENCE Practical Programming using Python Lesson 4 - Selection.
Unit 1 Logical operators.
Week 2 - Wednesday CS 121.
GCSE COMPUTER SCIENCE Practical Programming using Python
Component 1 Logical operators.
Lesson 1 - Sequencing.
Lesson 4 - Challenges.
Do it now activity Green pen activity in books.
Learning to Program in Python
Lesson 1 Learning Objectives
Learning to Program in Python
Fill the screen challenge!
Programming In Lesson 3.
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
GCSE Computing Lesson 6.
A look at Python Programming Language 2018.
PYTHON: BUILDING BLOCKS Inputs & Outputs
PYTHON: BUILDING BLOCKS Sequencing & Selection
B065: PROGRAMMING Variables 1.
Programming In Lesson 4.
Introduction to Python programming for KS3
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Data Types and Maths Programming Guides.
Python 4 and 5 Mr. Husch.
Starter Which of these inventions is: Used most by people in Britain
What you need to do… Drag the pieces of code into the correct order like you can see in the EXAMPLE below. print ( “ int input ) = + Hello world chr ord.
Hardware is… Software is…
Presentation transcript:

Python Programming Using Variables and input

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.

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)

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)

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…

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.

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.

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

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: To include input from an integer, you would use the following code: int(input())

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: To include input from a float, you would use the following code: float(input())

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

Example

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.

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.