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.

Slides:



Advertisements
Similar presentations
compilers and interpreters
Advertisements

Introduction to Programming using Matlab Session 2 P DuffourJan 2008.
COMPUTER PROGRAMMING Task 1 LEVEL 6 PROGRAMMING: Be able to use a text based language like Python and JavaScript & correctly use procedures and functions.
Creating a Program In today’s lesson we will look at: what programming is different types of programs how we create a program installing an IDE to get.
Java Programming Working with TextPad. Using TextPad to Work with Java This text editor is designed for working with Java You can download a trial version.
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
Compilers and Interpreters. Translation to machine language Every high level language needs to be translated to machine code There are different ways.
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.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Chapter 1: Python Basics CSCI-UA 0002 – Introduction to Computer Programming Mr. Joel Kemp.
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 2 Fundamentals of Programming Languages 4/5/09 Python Mini-Course: Day.
Introduction to Java Tonga Institute of Higher Education.
An Introduction to Textual Programming
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 1 Computers and Programs.
Introduction to Programming Peggy Batchelor.
COMP 171: Principles of Computer Science I John Barr.
 We are going to learn about programming in general…How to think logically and problem solve. The programming language we will use is Python. This is.
August 29, 2005ICP: Chapter 1: Introduction to Python Programming 1 Introduction to Computer Programming Chapter 1: Introduction to Python Programming.
Writing Scala Programs. Command Line There are three common operating systems: Windows (various flavors; I recommend Windows 7) UNIX or Linux (basically.
Python From the book “Think Python”
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Comments in Java. When you create a New Project in NetBeans, you'll notice that some text is greyed out, with lots of slashes and asterisks:
Lesson 4 Using Variables in Python – Creating a Simple ChatBot Program.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 1 Simple Python Programs Using Print, Variables, Input.
PROGRAMMING In. Objectives  We’re learning to develop basic code with the use of the correct syntax and variables. Outcomes  Explain what syntax is.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 17, 2015)
I Power Higher Computing Software Development Development Languages and Environments.
Programming for GCSE 1.0 Beginning with Python T eaching L ondon C omputing Margaret Derrington KCL Easter 2014.
IDLE An IDE for Python bundled with the program release Click on IDLE (Python GUI) in the Start menu under the Python program group  Get the IDLE Python.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 4: Writing programs.
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.
You Need an Interpreter!. Closing the GAP Thus far, we’ve been struggling to speak to computers in “their” language, maybe its time we spoke to them in.
ECET – Dynamic Programming with Python Spring 2013 Lecture L1 – Introduction to Python Page 1 Welcome! This is Professor Jai P. Agrawal. I will walk.
Software Development. Software Development Loop Design  Programmers need a solid foundation before they start coding anything  Understand the task.
CSC 1010 Programming for All Lecture 2 Introduction to Python Some material based on material from Marty Stepp, Instructor, University of Washington.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
9/2/2015BCHB Edwards Introduction to Python BCHB524 Lecture 1.
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 Python Lab 1: My First Program 8 January PythonLab1 lecture slides.ppt Ping Brennan
A Python Tour: Just a Brief Introduction "The only way to learn a new programming language is by writing programs in it." -- B. Kernighan and D. Ritchie.
1. Starting 1 Let’s Learn Saenthong School, January – February 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
First Program  Open a file  In Shell  Type into the file: 3  You did it!!! You wrote your first instruction, or code, in python!
Machine Language Computer languages cannot be directly interpreted by the computer – they are not in binary. All commands need to be translated into binary.
Introducing Python 3 Introduction to Python. Introduction to Python L1 Introducing Python 3 Learning Objectives Know what Python is and some of the applications.
2.1 First C Program. First Program Open visual studio, click new file Save as “programName.c” – Program must start with letter and have no spaces – Must.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Development Environment
CST 1101 Problem Solving Using Computers
Whatcha doin'? Aims: To start using Python. To understand loops.
A Python Tour: Just a Brief Introduction
Introduction to Python
Introduction to Programming
Introduction to Programming
A Short DOS Presentation
Introduction to Python
A451 Theory – 7 Programming 7A, B - Algorithms.
Introduction to Programming
Teaching Computing to GCSE
CS190/295 Programming in Python for Life Sciences: Lecture 1
COMPUTER PROGRAMMING PYTHON
ICT Programming Lesson 1:
Introduction to Python
Chapter 1: Programming Basics, Python History and Program Components
Input and Output Python3 Beginner #3.
General Computer Science for Engineers CISC 106 Lecture 03
The Python interpreter
Programming language translators
Presentation transcript:

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 humans use to communicate with the computer  Kind of like how you have to speak Italian if you travel to Italy  However, Python is known as a high level programming language, meaning that the computer doesn’t understand the code that you type in.  High level programming languages need to be either interpreted or compiled  Python is an interpreted language

COMPILED VS. INTERPRETED  A compiled language is one which uses a compiler to translate source code (the programs you write) into machine code  A compiler is a program that you have to install on your computer  Compiled programs are translated all at once into machine code  There are two different steps: compiling, then executing As soon as a program has been compiled, it can be run many times  Compiled languages are platform dependent, meaning there are different compilers for different operating systems (such as Windows or Mac)  Compiled languages are considered faster than interpreted languages

COMPILED VS. INTERPRETED (CONT.)  An interpreted language is one which uses an interpreter to translate source code into machine code  An interpreter is also a program that you must install on your computer  Interpreted languages are platform independent, meaning that a single interpreter can be used across many different operating systems  There is a single step: executing, which starts the interpreter  The interpreter then translates and executes the source code one line at a time  Interpreted languages are considered slower than compiled ones

YOUR FIRST PROGRAM!  Now that all that boring terminology is out of the way, let’s get programming!  Click on the Windows button and at the bottom, search for IDLE  Open the program that says IDLE (Python GUI)

THE PYTHON SHELL  When you open IDLE, you should see something that looks like this:  Notice how the window says Python shell. What do you think a shell is? A shell is a window that allows you to interact with the computer

MORE OF THE PYTHON SHELL  With the Python shell, you can interact directly with the computer.  The set of greater than symbols ‘>>>’ is a prompt. The computer is waiting for you to give it something to do.  Try typing in 16 * 5, then press Enter, what happens?

WRITING YOUR FIRST PROGRAM  Typing in commands at the shell only allows you to give the computer one command at a time. What if you want to give the computer a whole bunch of instructions?  That’s when you write a program A program is just a set of instructions for the computer  In order to write a program, you need to use a text editor, like Notepad. IDLE comes with a text editor  At the top of the shell, click File > New window

HELLOWORLD.PY  The first thing you’ll want to do is save your program. Whenever you save a Python program, you need to give it the ‘.py’ extension, so that the computer knows it’s a Python file  Kind of like ‘.doc’ is a Word document  Save your program, and call it helloWorld.py

MORE OF HELLOWORLD.PY  Type in the following  If you press Enter, what happens? NOTHING! We need to execute the program. At the top of the window, click Run > Run module

BREAKING DOWN HELLO WORLD  Let’s take this program apart line by line  The first line reads ‘def main():’ This is called a function header. It lets the computer know that main is a function  The next line reads ‘print “Hello world!” ’ This line is a statement (an instruction given to the computer) The line above it that begins with a # is called a comment. Comments are ignored by compilers and interpreters. They are notes to programmers.  The last line reads ‘main()’ This is a function call to main, and this is the line that actually starts the program

MORE BREAKING DOWN HELLO WORLD  What’s with all the indenting? Indenting is a part of Python syntax and a good programming practice. Indenting is used to delineate chunks of code that ‘belong’ to different parts of a program. Whenever you see a colon in Python, the next line usually has to be indented. The print statement is indented because it is part of the main function The line that reads ‘main()’ does not belong to the main function, which is why it is not indented

YOUR TURN!  Open the file called “Python – Lesson 1 Exercises” and complete the exercises  Don’t forget the.py extension when you save your program

CONGRATS! YOU MADE IT THROUGH YOUR FIRST PROGRAMMING LESSON!!