COMPUTER PROGRAMMING PYTHON

Slides:



Advertisements
Similar presentations
Order of operators: x ** y x * y, x / y, x // y, x % y x + y, x - y
Advertisements

Week 3. Assembly Language Programming  Difficult when starting assembly programming  Have to work at low level  Use processor instructions >Requires.
Programming Languages. Objectives Understand how programming has evolved Be able to write simple programs using a text based programming language.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
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: LESSON 1 Catherine and Annie. WHAT IS PYTHON ANYWAY?  Python is a programming language.  But what’s a programming language?  It’s a language.
From Scratch to Python Learn to program like the big boys / girls!
An Introduction to Textual Programming
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level language.
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 Basic Syntax. Basic Syntax - First Program 1 All python files will have extension.py put the following source code in a test.py file. print "Hello,
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
Python – Making Decisions Lecture 02. Control Structures A program that only has one flow is useful but limited. We can use if statements to make these.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Lesson 6. GCSE Computing – programming languages Candidates should be able to:  describe common tools and facilities available in an integrated development.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
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.
Module 3 Fraser High School. Module 3 – Loops and Booleans import statements - random use the random.randint() function use while loop write conditional.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)
For loops in programming Assumes you have seen assignment statements and print statements.
1 8/31/05CS150 Introduction to Computer Science 1 Hello World!
C++ LANGUAGE TUTORIAL LESSON 1 –WRITING YOUR FIRST PROGRAM.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Python Lesson 2.
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
GCSE Computing: Programming GCSE Programming Remembering Python.
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
Microsoft® Small Basic Conditions and Loops Estimated time to complete this lesson: 2 hours.
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.
GCSE COMPUTER SCIENCE Practical Programming using Python Lesson 4 - Selection.
Math operations 9/19/16.
Basic concepts of C++ Presented by Prof. Satyajit De
Development Environment
GCSE COMPUTER SCIENCE Practical Programming using Python
Introduction to Programming
Whatcha doin'? Aims: To start using Python. To understand loops.
Introduction to Programming
Week 4 Computer Programming Gray , Calibri 24
Lesson 4 - Challenges.
IF statements.
Introduction to Programming
Introduction to Programming
A451 Theory – 7 Programming 7A, B - Algorithms.
Variables, Expressions, and IO
The Little Crab Scenario
Week 3 Computer Programming Learning Objective:
Introduction to Programming
Fill the screen challenge!
Today’s lesson – Python next steps
Learning to Program in Python
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.
Mini Python Project Lesson 3.
Introduction to Programming
Introduction to Programming
Java Intro.
Week 4 Computer Programming Year 9 – Unit 9.04
Introduction to Programming
Starter answer these questions in your book
Conditional Logic Presentation Name Course Name
Programming In Lesson 4.
Introduction to Programming
Introduction to Python
Introduction to Programming
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.
Hardware is… Software is…
Lecture 20 – Practice Exercises 4
Presentation transcript:

COMPUTER PROGRAMMING PYTHON

Previously You saved a file that asked a user some questions, like what is your favourite food and where do you live. Can you find the file? Can you open it?

Add another question and response Add another question – ask the user to name a place where they have been on holiday. The response must be; “Hmmm…. “ + holiday_location + “sounds like a nice place to go”

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

Add more questions to your game Can you add more maths questions to your game questions? How many can you do? Did you do them on your own or did you need some help?

Can you answer this question? Answer = int(answer) Thinking back to the use of integers in the last 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? else

else Or else

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 (#)