= Introduction to Computer Programming Python Basics CSCI-UA 2 - - PowerPoint PPT Presentation

introduction to computer programming python basics csci
SMART_READER_LITE
LIVE PREVIEW

= 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-1
SLIDE 1

Introduction to Computer Programming Python Basics CSCI-UA 2

=

slide-2
SLIDE 2

Introduction to Computer Programming CSCI-UA 2

Python A general purpose, cross-platform programming language

Python Basics

High-level programming language Developed in the 1990s by Guido van Rossum Actively maintained and documented by programmers around the world Freely available Clear syntax General purpose usage Wide range of libraries available

slide-3
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
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
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
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
SLIDE 7

Introduction to Computer Programming Python Basics CSCI-UA 2

Input

Writing Programs

Processing

Design

Output

slide-8
SLIDE 8

Introduction to Computer Programming Python Basics CSCI-UA 2

slide-9
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
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
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
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
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
SLIDE 14

Introduction to Computer Programming Python Basics CSCI-UA 2

Arithmetic Operators

()

Highest precedence

**

to lowest precedence

% // * / +

slide-15
SLIDE 15

Introduction to Computer Programming Python Basics CSCI-UA 2