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.

Slides:



Advertisements
Similar presentations
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
Advertisements

Introduction to C Programming
Introduction to C++ September 12, Today’s Agenda Quick Review Check your programs from yesterday Another Simple Program: Adding Two Numbers Rules.
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
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to Python Programming Outline 2.1 Introduction 2.2 First Program in Python: Printing.
Guide to Programming with Python Chapter Two Basic data types, Variables, and Simple I/O: The Useless Trivia Program.
Python Programming Fundamentals
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.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Documentation and Comments. What’s a comment? A comment is a simple form of documentation. Documentation is text that you the programmer write to explain.
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.
COMP 171: Data Types John Barr. Review - What is Computer Science? Problem Solving  Recognizing Patterns  If you can find a pattern in the way you solve.
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.
Maths in Python [ slide 5 ] 1.Copy the table 2.Race a friend with a calculator to see whether Python is faster than a calculator: a) 5 * 6.5 = b)7 / 3.
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.
Introduction to Programming
COMPUTER PROGRAMMING Year 9 – Unit 9.04 Week 3. Open the Python INTERPRETER Can you use the interpreter to solve these maths problems? 156 add
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
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.
Foundations of Programming: Java
Introduction to Programming
Basic concepts of C++ Presented by Prof. Satyajit De
C++ First Steps.
GCSE COMPUTER SCIENCE Practical Programming using Python
Whatcha doin'? Aims: To start using Python. To understand loops.
A Playful Introduction to Programming by Jason R. Briggs
Introduction to Programming
Chapter 2 Introduction to C++ Programming
Lesson 1 - Sequencing.
Week 4 Computer Programming Gray , Calibri 24
Introduction to Python
Topic: Python’s building blocks -> Statements
Introduction to Programming
Introduction to Programming
Variables, Expressions, and IO
Introduction to Scripting
Learning to Program in Python
Lesson 1 Learning Objectives
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Learning to Program in Python
Week 3 Computer Programming Learning Objective:
Introduction to Programming
Week 5 Computer Programming Gray , Calibri 24
Learning to Program in Python
Learning Outcomes –Lesson 4
Week 5 Computer Programming Year 9 – Unit 9.04
COMPUTER PROGRAMMING PYTHON
Introduction to Programming
Week 4 Computer Programming Year 9 – Unit 9.04
Introduction to Programming
Starter answer these questions in your book
Chapter 3: Selection Structures: Making Decisions
Boolean Expressions to Make Comparisons
Programming In Lesson 4.
Chapter 3: Selection Structures: Making Decisions
Other types of variables
Introduction to Python
Introduction to Programming
How to organise your code
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.
Introduction to Programming
Hardware is… Software is…
Presentation transcript:

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 If you typed the code correctly this is what you should see

Learning Outcomes Lesson 5 Demonstrate and explain the practice of commenting on code Create a simple maths test. Explain the need to convert a string to an integer Make use of if statements to create a 12 times table

In a previous lesson You saved a file called questions. Can you find the file? Can you open it?

Commenting code Comments are added to computer programs to help people understand the intentions of the person who created the code – especially where it is not obvious what is going on.

# Now add comments to all of your lines of code ################ # Now add comments to all of your lines of code

Add comments to your program Think, pair, share 1. How would you add some information about the program, creator, date etc 2. Is it necessary to comment on every line? 3. If everything is ignored after the #, how could this be useful?

Answers 1. Add a top line comment with name, date etc 2. Only comment when it is not clear to another person 3. You can use the # to “comment out” sections of code that are not working to help with debugging

Creating a maths quiz Open a new program editor window (open the interpreter and select File, New Window)

Here is the code: save as maths_questions Discuss with pupils what they think each line of the code is doing Explain how the variable “answer” takes the value entered in response to the question This is an input The “int” function changes the input from text to a number The IF/ else function is used to give options. The responses to the answer are “outputs” Question pupils to see if they can work out what the double equals does == (means that this answer will not change) Unlike using = to set a variable value which can change throughout the program

Add more questions to your game Can you add 5 more maths questions to your game questions?

Can you answer this question? Answer = int(answer) Thinking back to the use of integers in a previous lesson, what does this do and what does int mean?

Answer = int(answer) This converts the text string into a number or integer. If it was not converted to an integer, it could not be compared to another integer, the answer 4.

Can you answer this question? if answer ==4: What does the == translate to in plain English?

if answer ==4: This means ‘equal’ to, as in “is it equal to?”

Can you answer this question? Why are the indents necessary after the if and else statements?

Indents This means follow the these instructions if the statement above is true.

Can you answer this question? What happens if the colons are not there after the 4 or else?

Colons You get a syntax error

12 times table Create a test that will check the user’s knowledge of the 12 times multiplication table. The test should have between 4 and 12 questions. Save the file as 12_times_table It must include a header (description, your name and date) You must make use of comments (#) # My name is.......this is my times table program and today's date is...... print("What is 1 x 12?") answer = input () answer = int(answer) if answer == 12: print("Well done") else: print("Sorry the answer was 12")

Use this slide if you feel that some pupils need additional support

Review –Lesson 3 Demonstrate and explain the practice of commenting on code Create a simple maths test. Explain the need to convert a string to an integer Make use of if statements to create a 12 times table

Quick quiz In coding, snippets of text are called ... strings [ slide 8 ] Quick quiz In coding, snippets of text are called ... strings Whole numbers are called ... integers Numbers with a decimal point are called ... floating point numbers (or floats) To use special Python characters we need ... escape sequences In Python, the remainder of a division is called ... modulus