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.

Slides:



Advertisements
Similar presentations
CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
Advertisements

ECS 15 if and random. Topic  Testing user input using if statements  Truth and falsehood in Python  Getting random numbers.
© 2010 Delmar, Cengage Learning Chapter 9: Using ActionScript.
Programming in python Lesson 2.
Python Magic Select a Lesson: Why Learn to Code? Basic Python Syntax
Python (yay!) November 16, Unit 7. Recap We can store values in variables using an assignment statement >>>x = We can get input from the user using.
PROGRAMMING In. STARTER Using the internet…Find …  what does “case sensitive” mean  what a programming language is..  3 benefits of Python.
PROGRAMMING In Lesson 5. RECAP  Complete the starter activity.
Fundamentals of Python: From First Programs Through Data Structures
Real World Programming BBrewer Fall Programming - Bellwork 1.Log on 2.Go to edmodo 3.Open & Save Vocabulary Graphic Organizer and Analaysis Document.
Noadswood Science,  To know the basics of Python coding and decoding Monday, September 07, 2015.
An Introduction to Textual Programming
Hands on Projects Dr. Bernard Chen Ph.D. University of Central Arkansas July 9 th 2012
Microsoft Visual Basic 2008: Reloaded Fourth Edition
Introduction to Python
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: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
30/10/ Iteration Loops Do While (condition is true) … Loop.
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.
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.
Python Programming Using Variables and input. Objectives We’re learning to use basic knowledge of variables combined with user input. Outcomes Continue.
PROGRAMMING In. Objectives  We’re learning to develop basic code with the use of the correct syntax and variables. Outcomes  Explain what syntax is.
Introduction to Python Lesson 1 First Program. Learning Outcomes In this lesson the student will: 1.Learn some important facts about PC’s 2.Learn how.
You Need an Interpreter!. Closing the GAP Thus far, we’ve been struggling to speak to computers in “their” language, maybe its time we spoke to them in.
Python Unit – : Operators, Expressions, and Variables
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.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Controlling Program Flow with Decision Structures.
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
Introduction to Programming Python Lab 6: Relational Operators and Boolean Variables 12 February PythonLab6 lecture slides.ppt Ping Brennan
PROGRAMMING In Lesson 6. RECAP  Discuss with the person next to you...  what you have enjoyed about python programming  What you have found difficult.
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)
Getting Started With Python Brendan Routledge
KEY STAGE 3 ICT Databases – Lesson 2. Recap of keywords – Task 2A In your workbooks from last lesson What is a database? A DATABASE is a collection of.
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.
GCSE COMPUTER SCIENCE Practical Programming using Python
Introduction to Programming
Whatcha doin'? Aims: To start using Python. To understand loops.
Introduction to Programming
Lesson 1 - Sequencing.
Week 4 Computer Programming Gray , Calibri 24
Week of 12/12/16 Test Review.
Lesson 4 - Challenges.
Frozen Graphics Lesson 3.
Python I/O.
Fill the screen challenge!
Today’s lesson – Python next steps
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.
Introduction to TouchDevelop
Week 4 Computer Programming Year 9 – Unit 9.04
Margaret Derrington KCL Easter 2014
A look at Python Programming Language 2018.
PYTHON: BUILDING BLOCKS Sequencing & Selection
Programming In Lesson 4.
Beginning Python Programming
Programming In.
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.
Presentation transcript:

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 self-assessment.

OBJECTIVES  Understand that languages have data types  Be able to use the idle editor to save programs  Understand if statement and indentation O UTCOMES  All-Level 4 Know the key data types discussed in lesson To be able to store a user input variable with help Write, save and run your first python program  Most-Level 5Be able to write a these with little help.  Some-Level 6Independently write these and adapt them

LETS RECAP LAST LESSON  What is a program? A program is a sequence of instructions that specifies how to perform a computation.  What is syntax? Refers to the spelling and grammar of a programming language  Variables – Boxes with numbers (or text) in.

PROGRAMS  We were not really writing programs last yesterday – they were statements. Programs are a sequence of many statements.  Lets write a program.  Open Idle (start menu, all programs, python 3.3)  Make sure you are in the editor.

MY FIRST REAL PORGRAM  Enter the following code print(“What is your name?") name = input() print(“Hello " + name)  Press F5, which runs the program. It will ask you to save it first - save the program into your lesson 2 folder call it hello

MY BETTER PROGRAM  See if you can adapt this to ask other questions.  Edit the program in the idle editor  Press f5 to run (and save it)  Write the number of other questions you asked into your self assessment book.

DATA TYPES – SAME AS IN DATABASES  Integer  Float  String “hello”“python”“4”“23.2”  Boolean TrueFalse  2 is NOT the same as 2.0 which is NOT the same as “2” Integer are whole numbers Float numbers have a decimal point Strings have start and end quotation marks Only has these 2 values

OUR FIRST GAME import random print("Hello! What is your name?") myName = input() number = random.randint(1, 10) print("Well, " + myName + ", I am thinking of a number between 1 and 10.") print("Take a guess.") guess = int(input()) if guess == number: print("Good job, " + myName + "! You guessed my number") Type this code into the idle editor Save it as “random one” Press f5 to run it Make sure you have 4 spaces here

LETS HAVE A LOOK AT THIS. import random print("Hello! What is your name?") myName = input() number = random.randint(1, 10) print("Well, " + myName + ", I am thinking of a number between 1 and 10.") print("Take a guess.") guess = int(input()) if guess == number: print("Good job, " + myName + "! You guessed my number") We re-using an existing piece of code to give us a random number Generates a random number between 1 and 10 and stores it in the variable number Converts the input from text to an integer The == is equal to

THE IF STATEMENT if guess == number: print("Good job, " + myName + "! You guessed my number") The print statement is run ONLY if the condition is True. Starts with if Guess == number the condition that evaluates to either True or False: is the end of the if statement. Notice the spaces. These are very important in python.

CONDITIONS Operator Sign Operator Name < Less than > Greater than <= Less than or equal to >= Greater than or equal to == Equal to != Not equal to 6 > 5 3 <= 4 2 == 3 4 = 5 45 != 2 3 == 3.0 Eggs > pizza True False Error, should be == True Error – remember data types Depends on the values of Eggs and pizza variables.

INDENTATION – 4 SPACES if 2 == 2: print("Good job, ") print (“you are good”) print (“Are we sure”) Which of these lines of code are run. yes if 24 == 87: print("Good job, ") print (“you are good”) print (“Are we sure”) Which of these lines of code are run. no yes Be very careful with spaces

CHALLENGES  Level 4 – Change the range of the random number to 1 to 20 Hint: change this statement number = random.randint(1, 10)  Level 5 - Display the random number if the user does not guess it Hint you might need this part of a statement if guess != number: This statement converts an integer type into a string type. number = str(number)  Level 6 - Let the user have 2 attempts to guess the number

PLENARY Update your self-evaluation for this lesson.

FUN TIME Try the tangram game Use left mouse button to drag, right mouse button clicks to turn tiles,