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.

Slides:



Advertisements
Similar presentations
COMPUTER PROGRAMMING Task 1 LEVEL 6 PROGRAMMING: Be able to use a text based language like Python and JavaScript & correctly use procedures and functions.
Advertisements

Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
Order of Operations - BiDMAS
An Introduction to Textual Programming
Introduction to Python
Section 3 Calculations National 4/5 Scratch Course.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
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.
Input, Output, and Processing
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)
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.
Lesson 4 Using Variables in Python – Creating a Simple ChatBot Program.
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.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
CSC Intro. to Computing Lecture 12: PALGO. Announcements Homework #3 solutions available  Download from Blackboard/web Quiz #3 will be in class.
PROGRAMMING In. Objectives  We’re learning to develop basic code with the use of the correct syntax and variables. Outcomes  Explain what syntax is.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 17, 2015)
Make a dice challenge! This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open IDLE 3.Copy the code below in.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
ICT Training Session #4 10 th February 2011 Using Microsoft Excel 2007  Exploring the home screen  Entering data  Formatting & sorting  Equations.
Lesson 4 Mathematical Operators! October 6, 2009.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Unit 7.4 Introduction to modelling & presenting numeric data Lesson 1 Setting up a basic spreadsheet.
Introduction to Programming
Python Lesson 2.
PHP Form Processing * referenced from
Thinking about programming Intro to Computer Science CS1510 Dr. Sarah Diesburg.
GCSE Computing: Programming GCSE Programming Remembering Python.
Groups of cells labeled with letters that go up and down (vertical)
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.
Getting Started With Python Brendan Routledge
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
Development Environment
Introduction to Programming
Whatcha doin'? Aims: To start using Python. To understand loops.
A Playful Introduction to Programming by Jason R. Briggs
Introduction to Programming
Lesson 1 - Sequencing.
Introduction to Programming
Introduction to Programming
Variables, Expressions, and IO
Lesson 1 Learning Objectives
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Introduction to Programming
Fill the screen challenge!
Today’s lesson – Python next steps
Introduction to Excel Spreadsheets I can…
Learning Outcomes –Lesson 4
Teaching London Computing
Task 1 Computer Programming LEVEL 6 PROGRAMMING:
G7 programing language Teacher / Shamsa Hassan Alhassouni.
Introduction to Programming
Introduction to Programming
Introduction to Programming
Programming In Lesson 4.
Beginning Python Programming
Introduction to Programming
12th Computer Science – Unit 5
Introduction to Programming
Input and Output Python3 Beginner #3.
Introduction to Python
Introduction to Programming
Starter Which of these inventions is: Used most by people in Britain
Hardware is… Software is…
Python Creating a calculator.
Presentation transcript:

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 A4 divided by B4

Objective of the lesson Write simple programs using Python. All of you will: – Create simple code including the input and print scripts. Most of you will: – Create variables and declare the data types for variables. Some of you will: – Use operators to effectively create programs to solve a number of scenarios. 3

Everybody should complete Tasks 1 to 3 to download Python and create the program to to your teacher. Some of you may also want to get the extra marks by completing the extension activity. This homework is due in next lesson. Make sure you have written your homework clearly in your planner. 4 Homework

Python Python is a programming language which was developed to help you learn programming. You will learn about the basics of programming using Python. To use Python load Python (IDLE). 5

The Python Shell Shell The first screen you see is called the “Shell”. You can type in simple commands straight into the shell. 6

Typing into the Shell Type in 4+2 at the >>> prompt and hit your Enter key. What happens? You can type in calculations into the Shell exactly as you would normally. What symbols would you use for multiply and divide? 7

Typing calculations into the shell Try typing the following calculations into the shell: – 7 take away 3 – 4 multiplied by 3 – 10 divided by 3 – 2 add 4 then multiply the total by 5 (remember how you can specify the order of calculation by using brackets) – take away 321 and then divide by 2 8

Creating a simple program If you want to create a program that has more than one line of code in it then you will need to use a new window to do this. File New Window Click on the File menu and select New Window. 9

Type into the new window Type the following into the new window (it is case sensitive): What do you think this code will do? Hello.py Save the code as Hello.py (It is important to add the.py at the end as your code will not work without it). F5 To run the code in the Shell hit the F5 key on your keyboard. 10

Change your code Change your code to the following: 11 Input is used to tell Python that you want the user to enter a response Variable Name tells Python that you want it to remember the answer you type in and call that “Firstname”

Change your code 12 {0} is known as a placeholder. This tells Python that you want to put something in this place..format(Variable Name) tells Python what you want to put into the placeholder

Change your code 13 Be careful: it is case sensitive (input and print should NOT have capital letters) Save and run your code (F5) to try it out

Keywords 14 WordWhat this does print This will show whatever you want in the Python Shell input This will ask the user a question in the Python Shell and expect a response variable These are pieces of data that Python needs to remember for later use placeholder This tells Python that you want to insert something (e.g. the data stored in the variable)

What will this code do? Try it out. You can use more than one placeholder as shown below: Placeholders are numbered {0}, {1}, {2} … etc in the order that the variable names appear in the format brackets. 15

Data types Try entering the following: When you run the script it will not work as you may expect. Try to work out what it is actually doing. 16

Data Types When the user inputs data it is automatically classed as text, even if they only enter a number. This is known as a string. In Python, if you want to treat the value as a number you will need to specify the data type when you create the variable. 17

Declaring a data type What is different in this line of code? 18 int( tells Python that the input is going to be treated as an integer (number). ) closes the “int” bracket

Change your code Change the code you have just created so that it treats both inputs as a number. Run the code again and you should see that it now works. 19

Operators OperatorWhat it meansExample + Addition >>> 4+5 >>> 9 - Subtract >>> 5 – 1 >>> 4 * Multiply >>> 7 * 3 >>> 21 / Divide >>> 7/4 >>> 1.75 // Whole number division >>> 20 // 3 >>> 6 % Remainder after whole number division >>> 20 % 3 >>> 2 20

Python Exercises Work through the worksheet creating the programs you are asked to. The operator table at the top of the page will help you complete the programs. Make sure you save them with sensible names. 21