Beginning Python Programming

Slides:



Advertisements
Similar presentations
Python November 14, Unit 7. Python Hello world, in class.
Advertisements

 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to Python Programming Outline 2.1 Introduction 2.2 First Program in Python: Printing.
Introduction to Python
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #002 (January 17, 2015)
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Introduction to Computational Linguistics Programming I.
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
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
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.
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.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
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.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 17, 2015)
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.
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.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
NAME Python Programming Workbook Select a Lesson:
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 1 SIGCS 1 Intro to Python March 7, 2012 Presented by Pamela A Moore & Zenia C Bahorski 1.
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.
Introduction to Python Lesson 2a Print and Types.
Python Fundamentals: Hello World! Eric Shook Department of Geography Kent State University.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Few More Math Operators
Thinking about programming
Math operations 9/19/16.
CS 106A, Lecture 4 Introduction to Java
Development Environment
More about comments Review Single Line Comments The # sign is for comments. A comment is a line of text that Python won’t try to run as code. Its just.
Whatcha doin'? Aims: To start using Python. To understand loops.
Topics Designing a Program Input, Processing, and Output
A Playful Introduction to Programming by Jason R. Briggs
Topic Pre-processor cout To output a message.
Python: Experiencing IDLE, writing simple programs
Lesson 1 - Sequencing.
Introduction to Python
Pamela Moore & Zenia Bahorski
Lesson 1 An Introduction
Variables, Expressions, and IO
Thinking about programming
Introduction to Scripting
Functions CIS 40 – Introduction to Programming in Python
Intro to PHP & Variables
Lesson 1 Learning Objectives
Introduction to C++ Programming
Learning Outcomes –Lesson 4
Teaching London Computing
Lesson Aims Vocabulary In this lesson you are going to:
“If you can’t write it down in English, you can’t code it.”
Task 1 Computer Programming LEVEL 6 PROGRAMMING:
G7 programing language Teacher / Shamsa Hassan Alhassouni.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Operations Python code.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
12th Computer Science – Unit 5
Winter 2019 CISC101 4/28/2019 CISC101 Reminders
Unit 3: Variables in Java
Output Manipulation.
Programming In.
Introduction to Python
Introduction to Python programming for KS3
Starter Which of these inventions is: Used most by people in Britain
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Beginning Python Programming

Getting Started IDLE is Python’s Integrated Development Environment (IDE) and interpreter IDLE looks like a text editor but understands Python Run IDLE and look at the Shell (Python’s interpreter) Python version Prompt The print() command means ‘show on the screen’ not ‘send to the printer’ At the prompt, type in: print(“Hello World”) and press <Enter> 2 of 12

Don’t panic! These messages are trying to help you! Did it work?! IDLE allows you type a single line of code and run it You should see this: You might have an error like this: Don’t panic! These messages are trying to help you! Beginning Python 3 of 12

Syntax Errors Syntax errors are mistakes in your use of a programming language; rather like saying “I are going to the shops” in English… A string literal is something in quotes… Try all these… 4 of 12

I’m sure you can come up with some better jokes than these! Challenge 1 Write some to code to tell your favourite (polite) joke… Hint: You need to type two separate print() commands Q: What washes up on tiny beaches? A: Microwaves Q: What goes clip? A: A one-legged horse Q: Why shouldn’t you write with a broken pencil? A: Because it’s pointless! Q: How do you make a fire with two sticks? A: Make sure of them is a match! I’m sure you can come up with some better jokes than these! 5 of 12

Try out all of the escape sequences… Can we do this with one line of code? How can we put a blank line in a string? We can’t type it in… We can use an escape sequence Escape Sequence Effect \n Creates a new line \t Inserts a tab indent \\ Allows a backslash to appear in a string of text \” Allows a speech mark to be used in a string of text Try out all of the escape sequences… Beginning Python 6 of 12

Mathematical Operators You can use the Python interpreter as a calculator Operator Name Example Answer + add 17+3 20 - subtract 20-11 9 * multiply 15*3 45 / divide (normal) 11/5 2.2 // integer divide (the whole number part only) 11//5 2 % modulus (remainder of a division) 11%5 1 ** exponent (to the power of…) 10**2 100 Try these out… Beginning Python 7 of 12

What is print( )? print() is a built-in function; a small program included in Python to perform a particular task print() expects a value within the brackets. This is called an argument or parameter, it is passed to the print() function. print() displays the passed value on the screen Someone wrote the print() function… You will learn to write your own functions later on. Beginning Python 8 of 12

Putting it together You can pass multiple things to the print function Commas are used to separate different parts of the things we want to be displayed The print function inserts a space between each part Things in quotes are printed as they are, things with no quotes are evaluated and the result printed… Beginning Python 9 of 12

Exercises Display "15 cubed is", followed by the answer Display the following using one line of code: Welcome to my program I’d just like to say "hello!" Fix the following Python statement: Print("Good afternoon") Fix the following Python statement: print("17 / 5 =" 17/5) Beginning Python 10 of 12

Exercise Solutions . You need to use a escape sequences here (\n and \”) Python is case sensitive, it is print(), not Print() You must separate all parts of a print statement with commas Beginning Python 11 of 12

Summary We have looked at: IDLE and used the Shell (Python’s interpreter) The print() function Escape sequences Mathematical operators Combining strings and maths Beginning Python 12 of 12