Week 3 Computer Programming Learning Objective:

Slides:



Advertisements
Similar presentations
CS 1 with Robots Variables, Data Types & Math Institute for Personal Robots in Education (IPRE)‏
Advertisements

Jeopardy! One Step Equations. Grid Sheet 100 pts.200 pts. 300 pts. 400 pts.500 pts. Vocab Add Subtract
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.
Python Programming Fundamentals
Introduction to Python
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #002 (January 17, 2015)
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
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.
Input, Output, and Processing
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.
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.
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.
Evaluating a Variable Expression To evaluate a variable expression:
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 1 Simple Python Programs Using Print, Variables, Input.
Introduction to Computer Programming
Warm up #2 Ch 1: SIMPLIFY if possible Try These
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.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
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.
Introduction to Programming
Data Manipulation Variables, Data Types & Math. Aug Variables A variable is a name (identifier) that points to a value. They are useful to store.
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
Expressions and Equations 5.ATO.1 Evaluate numerical expressions involving grouping symbols (i.e., parentheses, brackets, braces). 5.ATO.2 Translate verbal.
GCSE Computing: Programming GCSE Programming Remembering Python.
* Collect the like terms 1. 2a = 2a x -2x + 9 = 6x z – – 5z = 2z - 6.
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.
Python Fundamentals: Hello World! Eric Shook Department of Geography Kent State University.
Introduction to Programming
Introduction to Programming
Math operations 9/19/16.
Topics Designing a Program Input, Processing, and Output
Week 4 Computer Programming Gray , Calibri 24
Variables, Expressions, and IO
Introduction to Programming
Writing Expressions and Equations
Fill the screen challenge!
Learning Outcomes –Lesson 4
Week 2 Computer Programming Learning Objective:
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.
Variables in Algebra Chapter 1 Section 1.
Teaching London Computing
Story time Task 5 Computer Programming Gray , Calibri 24
COMPUTER PROGRAMMING PYTHON
EQ: How do I solve an equation in one variable?
Task 1 Computer Programming LEVEL 6 PROGRAMMING:
Week 4 Computer Programming Year 9 – Unit 9.04
Chapter 1-1 Variables and expressions
Introduction to Programming
Divide the number in C by 10.
Variables, Data Types & Math
Variables and Expressions
THE COMPUTE STATEMENT Purpose: performs mathematical calculations
Variables, Data Types & Math
Python 19 Mr. Husch.
Topics Designing a Program Input, Processing, and Output
Variables and Expressions
Topics Designing a Program Input, Processing, and Output
Variables and Expressions
Variables, Data Types & Math
Learning Intention I will learn about the different types of programming errors.
Introduction to Programming
Variables and Expressions
Python 19 Mr. Husch.
Hardware is… Software is…
Warm up #2 Ch 1: SIMPLIFY if possible
COMPUTING.
Python Creating a calculator.
Presentation transcript:

Week 3 Computer Programming Learning Objective: Gray 80 69 69 69, Calibri 24 Dark Red RGB 153 0 0, Calibri 54 Learning Objective: To be able to use #Comments in your Code To understand what =variables are To be able to use = to assign variables

BUT 156 add 567 132 subtract 46 256 divided by 8 389 multiplied by 13 Open the Python INTERPRETER Can you use the interpreter to solve these maths problems? 156 add 567 132 subtract 46 256 divided by 8 389 multiplied by 13 >>> print(156 + 567) 723 >>> print(132 - 46) 86 >>> print(256 / 8) 32.0 >>> print(389 * 13) 5057 In computing, the mathematical operators are as you’d expect them to be: Add is + Subtract is – BUT Divide is / Multiply is * (asterisk Shift + 8)

My_name = ‘Sydney’ We can also assign numbers >>> pizza = 250 Last week we learnt about variables and assignment. We learnt how to assign data (such as a word) to a variable! My_name = ‘Sydney’ A word is also known as a String [just a bunch of letters!] We can also assign numbers >>> pizza = 250 >>> coke = 100 >>> chips = 150 Some interesting expressions can then be evaluated such as: >>> pizza + chips 400 >>> 2 * pizza 500

Use the HASH key (#) after the line of code you want to comment # Comment Your Code Comments are often added to computer programs to allow people to understand the intentions of the person who created the code. The Python interpreter ignores the comments completely, so syntax is not a problem. In practise, it is not necessary to comment every line/section – only where it is not obvious what is going on. Use the HASH key (#) after the line of code you want to comment Look at how comments have been used in the program below…

# Commenting On Your Code Consider these 3 questions… How could you add some information about the program, creator, date etc.? Answer- add a top line comment with name, date etc.   2. Is it necessary to comment on every single line? Answer- Only comment when it is not clear to another person 3. If the interpreter ignores everything after the #, how else could this be useful? [harder question] Answer- You can use # to ‘comment out’ sections of code that are not working to help with debugging.

Locate your Python program called InteractiveProgram.py and open it. # Comment Your Code Locate your Python program called InteractiveProgram.py and open it. Use comments to add… your name and date [at the top] The purpose of the program [on the second line] Meaning to any line of code so it makes sense to someone else reading it. line of code you wan # # # # # # # # # #

How a calculator works We input our first number – 9 We then select the operator (the divide sign) Gray 80%

How a calculator works When we input our second number 4, nine disappears along with the operator divide. They are placed into memory 9 / Internal Memory Gray 80%

How a calculator works The equals sign will return both the 9 and the operator in order to work out the answer and return it to screen Internal Memory 9 / Gray 80%

Our calculator program Our calculator program will add up two numbers and then return the answer to the screen Gray 80%

Our calculator program The program explained #red writing is useful comments numb1 and num2 variables which will be located memory Gray 80% The variable ans is assigned the sum ans = 14 + 8 ans will be printed as 22 22

Running our Python program The star is telling us we have not saved the program Save it as adding.py. Push F5 on the keyboard to run Gray 80%

A temporary value in memory What Language are we using? Describe a variable? What does this = mean? Python sound A temporary value in memory Gray 80% x = x + 1 Assign to

Name a function we had used? What are letters known as in programming? x = input(Enter name) Where is the error here? print() or input() A string 48 No speech marks CLICK HERE FOR PLENARY