Introduction to Python

Slides:



Advertisements
Similar presentations
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Advertisements

PROGRAMMING In. STARTER Using the internet…Find …  what does “case sensitive” mean  what a programming language is..  3 benefits of Python.
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.
Introduction to Python
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 2.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
August 29, 2005ICP: Chapter 1: Introduction to Python Programming 1 Introduction to Computer Programming Chapter 1: Introduction to Python Programming.
Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source.
Python From the book “Think Python”
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
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.
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.
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.
Python Let’s get started!.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
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.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Introducing Python 3 Introduction to Python. Introduction to Python L1 Introducing Python 3 Learning Objectives Know what Python is and some of the applications.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Learning to use a ‘For Loop’ and a ‘Variable’. Learning Objective To use a ‘For’ loop to build shapes within your program Use a variable to detect input.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Basic Programming I Working with QBasic
Fundamentals of Programming I Overview of Programming
Introducing Python Introduction to Python.
Development Environment
CST 1101 Problem Solving Using Computers
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.
Introduction to Computing Science and Programming I
Writing algorithms Introduction to Python.
Agenda Introduction Computer Programs Python Variables Assignment
Introduction to Programming
Whatcha doin'? Aims: To start using Python. To understand loops.
A Playful Introduction to Programming by Jason R. Briggs
Introduction to Programming
Topics Introduction Hardware and Software How Computers Store Data
Python Let’s get started!.
Chapter 2 - Introduction to C Programming
Lesson 1 An Introduction
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Variables, Expressions, and IO
Basic operations in Matlab
G7 programing language Teacher / Shamsa Hassan Alhassouni.
Chapter 2 - Introduction to C Programming
Today’s lesson – Python next steps
Topics Introduction to File Input and Output
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
First Python Program Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
Teaching London Computing
Topics Introduction Hardware and Software How Computers Store Data
T. Jumana Abu Shmais – AOU - Riyadh
Task 1 Computer Programming LEVEL 6 PROGRAMMING:
Hello World! Syntax.
Topics Designing a Program Input, Processing, and Output
Section 1 Introduction To Programming
12th Computer Science – Unit 5
Chapter 1: Programming Basics, Python History and Program Components
Chopin’s Nocturne.
Programming In.
Introduction to Python
General Computer Science for Engineers CISC 106 Lecture 03
Topics Introduction to File Input and Output
CMPT 120 Lecture 3 - Introduction to Computing Science – Programming language, Variables, Strings, Lists and Modules.
Starter Which of these inventions is: Used most by people in Britain
Hardware is… Software is…
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Introduction to Python Introducing Python 3 Introduction to Python

Learning Objectives All to know what Python is and some of the applications it is used for Most to write, save and run a program in Script mode Some to understand the use and value of comments in a program

Frying an Egg Sequencing Instructions: What is the correct order of these instructions? Put pan on hob Break egg Get frying pan Put oil in pan Turn on hob Hold egg over pan

Programming Sequencing Instructions Sequence Order Important Accuracy Important

Frying an Egg Get frying pan Put pan on hob Turn on hob Put oil in pan Hold egg over pan Break egg

Example Code

Python Language Simple to Learn Used by: Nokia NASA Paint Shop Pro Google’s Search Engine Civilisation 4 Computer Game CERN Large Hadron Collider Research

Python’s Development Environment Called IDLE – Integrated Development Environment Two Modes: Interactive Mode let you see your results as you type them Script Mode lets you save your program and run it again later

“Hello World!” A programming tradition A simple program to display text on the screen In IDLE’s Interactive Mode type: print ("Hello World!") Press Enter Try again with some different text.

Getting it Wrong Syntax Errors Experiment with errors In IDLE type the following erroneous lines: primt ("Hello World!") Print ("Hello World!") print (Hello World!) print "Hello World!"

De-Bugging Syntax Errors Reading interpreter feedback Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> primt ("Hello World!") NameError: name 'primt' is not defined

Computer Bugs The name ‘Bug’ refers to an error in a program Thought to come from a real bug that crawled into some cogs in an early machine and stopped it working

Using Script Mode In IDLE, Open a New Window Type: print ("What is your name?") firstname = input() print ("Hello,",firstname) Save the program as MyFirst.py Press F5 to ‘Execute’ or Run the program

What is a variable? A variable is a location in memory in which you can temporarily store text or numbers It is used like an empty box or the Memory function on a calculator You can choose a name for the box (the “variable name”) and change its contents in your program

Rules for Naming Variables A variable name can contain only numbers, letters and underscores A variable name cannot start with a number You can’t use a Python “reserved word” as a variable name – for example class is a reserved word so class = input() will result in a syntax error.

Using a Variable print ("What is your name?") firstname = input() print ("Hello,",firstname)

Adding Comments Comments are useful to help understand your code They will not affect the way a program runs Comments appear in red Comments have a preceding # symbol #firstname is a variable print ("What is your name?") firstname = input() print ("Hello,",firstname)

Functions Functions are special keywords that do a specific job Functions appear in purple print() and input() are examples of functions print ("What is your name?") firstname = input() print ("Hello,",firstname)

Finally… Complete the plenary questions to show me what you have learnt today. Plenary questions should be completed and are available on the iTeach website