SLIDE 1
= Introduction to Computer Programming Python Basics CSCI-UA 2 - - PowerPoint PPT Presentation
= Introduction to Computer Programming Python Basics CSCI-UA 2 - - PowerPoint PPT Presentation
Introduction to Computer Programming Python Basics CSCI-UA 2 = Introduction to Computer Programming Python Basics CSCI-UA 2 High-level programming language Python Developed in the 1990s by Guido van A general purpose, Rossum
SLIDE 2
SLIDE 3
Introduction to Computer Programming Python Basics CSCI-UA 2
Python In Use
Web and Internet development Scientific and numeric computing Education Desktop GUIs Software Development
SLIDE 4
Introduction to Computer Programming Python Basics CSCI-UA 2
We will be using Python 3
Python
python.org/download
Installation
Versions available for Mac, Windows, and Linux
SLIDE 5
Introduction to Computer Programming Python Basics CSCI-UA 2
We’ll be using IDLE to write, run, and
Python
debug our code
Integrated Development
Interactive mode
Environment
Script mode
SLIDE 6
Introduction to Computer Programming Writing Programs with Input and Output CSCI-UA 2
A program is just a text file containing
Writing Programs
Python statements A program can have two lines of code
- r thousands
Any plain text editor can be used Give your files the extension “.py” Python executes the file by running all the statements from top to bottom
SLIDE 7
Introduction to Computer Programming Python Basics CSCI-UA 2
Input
Writing Programs
Processing
Design
Output
SLIDE 8
Introduction to Computer Programming Python Basics CSCI-UA 2
SLIDE 9
Introduction to Computer Programming Python Basics CSCI-UA 2
Functions A function is a reusable chunk of code
Examples: print() input() Function name and arguments Parentheses essentially mean “execute this function” Some functions take no input
SLIDE 10
Introduction to Computer Programming Writing Programs with Input and Output CSCI-UA 2
Functions print()
One of the most common built-in functions we will use Important in our standalone Python programs for providing output Additional arguments to the print function include separator, end character Separator default sep = ' ' End character default end = '\n'
SLIDE 11
Introduction to Computer Programming Writing Programs with Input and Output CSCI-UA 2
Functions input()
Reading strings from the keyboard Input function variable = input('Prompt ') Input can be in the form of a string or numeric data type However, the value is always assigned to a variable as a string
SLIDE 12
Introduction to Computer Programming Python Basics CSCI-UA 2
Variables =
A variable is a name that refers to a value An “assignment statement” gives a value to a variable Variables remember things Variables can change, too = is Python’s assignment token
SLIDE 13
Introduction to Computer Programming Python Basics CSCI-UA 2
Variables Naming
Can be of any length Characters must be letters, numbers,
- r the underscore (_)
First character cannot be a number Case sensitive Python keywords cannot be used as variable names
SLIDE 14
Introduction to Computer Programming Python Basics CSCI-UA 2
Arithmetic Operators
()
Highest precedence
**
to lowest precedence
% // * / +
SLIDE 15