Www.computerscienceuk.com From Scratch to Python Learn to program like the big boys / girls!

Slides:



Advertisements
Similar presentations
A Level Computing#BristolMet Session Objectives#U2 S2 MUST describe the steps of an algorithm using a program flowchart SHOULD explain the data types and.
Advertisements

PSEUDOCODE & FLOW CHART
Programming in python Lesson 2.
1 9/26/08CS150 Introduction to Computer Science 1 Logical Operators and if/else statement.
1 9/28/07CS150 Introduction to Computer Science 1 Logical Operators and if/else statement.
Computing Theory: BBC Basic Coding Year 11. Lesson Objective You will: Be able to define what BBC basic is Be able to annotate BBC basic code Be able.
The Scratch Calculator You are all going to be real computer programmers!!!
An Introduction to Textual Programming
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 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.
Section 2 Variables National 4/5 Scratch Course. What you should know after this lesson What a variable is Where variables are stored How to get data.
Agenda  Commenting  Inputting Data from Keyboard (scanf)  Arithmetic Operators  ( ) * / + - %  Order of Operations  Mixing Different Numeric Data.
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
Learning the skills for programming Advanced Visual Programming.
By the end of this session you should be able to...
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
Scratch Programming Lesson 4 Question asking and answering.
Making Decisions uCode: October Review What are the differences between: o BlueJ o Java Computer objects represent some thing or idea in the real.
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.
Fill the screen challenge! This is a starter activity and should take 3 minutes [ slide 1 ] 1.Log in to your computer 2.Open IDLE 3.In interactive mode,
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.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
Python Selection. All the programs you have been developing so far have been sequential, this means that each instruction is executed in a set order.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Using variable Variables are used to store values.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
GCSE Computing: Programming GCSE Programming Remembering Python.
31/01/ Selection If selection construct.
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.
Special Methods in Java. Mathematical methods The Math library is extensive, has many methods that you can call to aid you in your programming. Math.pow(double.
GCSE Computing: Programming GCSE Programming Remembering Python.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
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.
Input, Output and Variables GCSE Computer Science – Python.
GCSE COMPUTER SCIENCE Practical Programming using Python Lesson 4 - Selection.
PYTHON PROGRAMMING Year 9. Objective and Outcome Teaching Objective Today we will look at conditional statements in order to understand how programs can.
GCSE COMPUTER SCIENCE Practical Programming using Python
Whatcha doin'? Aims: To start using Python. To understand loops.
3.1 Fundamentals of algorithms
Lesson 1 - Sequencing.
Introducing Instructions
IF statements.
Variables, Expressions, and IO
Computational Thinking
Computational Thinking
Iterations Programming Condition Controlled Loops (WHILE Loop)
Introduction to Programming
Learning to Program in Python
Programming In Lesson 3.
Learning Outcomes –Lesson 4
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.
Selection (IF Statements)
COMPUTER PROGRAMMING PYTHON
Introduction to Programming
Python 19 Mr. Husch.
Programming In Lesson 4.
Introduction to Programming
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 19 Mr. Husch.
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:

From Scratch to Python Learn to program like the big boys / girls!

Lesson Objectives Remember how we program inputs/outputs/variables Remember what a variable’s data type means Remember how to tell the computer which data type a variable is Learn how programs make decisions in Python Lesson Outcomes Carrying out a number of programming tasks. Literacy – Key Words Data TypeThe type of data being used by the program VariableThe place where inputs get stored by the program Integer“Whole Number” data type SelectionA control structure which allows programs to make decisions

Starter On your white boards, write a program which asks the user for two numbers, adds then together, then displays the result.

Can you tell me the following…? 1.The python code needed to display a word on the screen 2.The python code needed to ask the user for an input 3.The way python can store user inputs

Dealing with numbers in Python The need to convert “Data Types” Above you can see that two numbers have been entered and stored in variables num1 and num2. As python stores inputs as strings we need to convert these variables into integers and to do this we have applied the int() function

What’s going on? Variable 29 Variable Twenty Nine 29 Mr Int. Num1 Twenty Nine I’m telling the computer that this variable contains a number not a word!

Once they have been converted we’re ready to do maths! Num1 Five Num2 Nine Num1 Five Num2 Nine Answer 14 Answer 14

Decisions (Selection)

Decisions in Python Programs The Virtual Barman What would be needed to make a program which: Acted like a barman, who had to make the decision on whether or not to serve the customer based on their age?

The Program At Work… ? How

How would we start? What would the barman do? Ask the customer for their age What must our program do? Ask the user for their age! How? Age = input(“What is your age?”)

Python and Integers? age = input(“What is your age?”) If python is to work with numbers what must we do to the input? Convert the variable (age) to an integer data type! How? age = int(age)

What next? If the real barman was told the customers age what would the barman do next? MAKE A DECISION!

Selection If we want the computer to make a decision based on our input we use “selection”. Selection uses If – Else statements Outcome 1 Outcome 2

Our Program IF age > 17 do this ELSE, do that IF – ELSE statements allow programs to make decisions based on certain conditions occurring. What is your age? “What can I get you?” “Go home boy!”

How are decisions programmed in Python? When you use selection statements you must indent accordingly. Colons are needed at the end of each IF and ELSE statement

So how can we program our Barman Program? Write down your code on a whiteboard! A Solution: START Age? Convert to Integer IF Age > 17 DISPLAY “Go home boy!” DISPLAY “What can I get you young sir?” A Flowchart to Help!

Comparison Operators In IF statements we will be looking to compare some data. – We might want to see if a variable is equal to a number or a piece of text. – We might want to see if a variable contains a number greater than another – Or contains a number smaller than another. In python we use certain symbols to compare data. – To see if something is mathematically equal to another we use a double equals sign (==) – To see if a variable contains a number greater than another we use the greater than symbol (>) – To see if a variable contains a number smaller than another we use the less than symbol (<)

How do these two pieces of code differ?

Tasks 1.Create your own BARMAN program using IF Statements 2.Comment your code!! Using # comments 3.Work through the worksheet producing more programs which use IF Statements Get some headphones and watch the video on IF Statements if you need a helping hand!