Introduction to Programming in Python (1)

Size: px
Start display at page:

Download "Introduction to Programming in Python (1)"

Transcription

1 to Programming in Python (1) Steve Renals ICL 26 September 2005 Steve to Programming in Python (1)

2 Announcements Lab sessions: Groups listed on the web: Steve to Programming in Python (1)

3 Overview Running programs Modules Numbers and variables Strings Lists Dictionaries Conditionals Loops Steve to Programming in Python (1)

4 Overview Running programs Modules Python books Mark Lutz and David Ascher (2004). Learning Python, 2nd Edition, O Reilly. Allen Downey, Jeff Elkner and Chris Meyers (2001), How to Think Like a Computer Scientist: Learning with Python, Green Tea Press. David Beazley (2001), Python Essential Reference, 2nd edition, New Riders. Mark Lutz (2002). Python Pocket Reference, 2nd Edition, O Reilly. Mark Lutz (2001). Programming Python, 2nd Edition, O Reilly. (O Reilly books available via on the web Safari Books Online: Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

5 Overview Running programs Modules Python features Free, portable, powerful Steve to Programming in Python (1)

6 Overview Running programs Modules Python features Free, portable, powerful Easy to mix in components from other languages Steve to Programming in Python (1)

7 Overview Running programs Modules Python features Free, portable, powerful Easy to mix in components from other languages Object-oriented (including operator overloading, polymorphism, multiple inheritance) Steve to Programming in Python (1)

8 Overview Running programs Modules Python features Free, portable, powerful Easy to mix in components from other languages Object-oriented (including operator overloading, polymorphism, multiple inheritance) Easy to use, easy to learn, easy to understand Steve to Programming in Python (1)

9 Overview Running programs Modules Python features Free, portable, powerful Easy to mix in components from other languages Object-oriented (including operator overloading, polymorphism, multiple inheritance) Easy to use, easy to learn, easy to understand NLTK and NLTK-Lite are Python packages that we will use in ICL (Learning Python, chapter 1) Steve to Programming in Python (1)

10 Overview Running programs Modules Using Python interactively The easiest way to use Python initially is interactively: % python2.4 >>> print ICL ICL >>> print 3*4 12 >>> print 2** >>> myname = Steve >>> myname Steve (Learning Python, chapter 3) Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

11 Overview Running programs Modules Using Python interactively The easiest way to use Python initially is interactively: % python2.4 >>> print ICL ICL >>> print 3*4 12 >>> print 2** >>> myname = Steve >>> myname Steve (Learning Python, chapter 3) Can also use the IDLE environment: idle2.4 (X)Emacs users have python-mode. Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

12 Overview Running programs Modules Modules To save code you need to write it in files Module: a text file containing Python code Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

13 Overview Running programs Modules Modules To save code you need to write it in files Module: a text file containing Python code Example: write the following to file foo.py: print 25*3 # multiply by 3 print ICL + lecture 2 # concatenate strings using + myname = Steve (No leading spaces!) Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

14 Overview Running programs Modules Modules To save code you need to write it in files Module: a text file containing Python code Example: write the following to file foo.py: print 25*3 # multiply by 3 print ICL + lecture 2 # concatenate strings using + myname = Steve (No leading spaces!) Then run it as follows: % python foo.py 75 ICL lecture 2 % Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

15 Overview Running programs Modules Importing modules Every file ending in.py is a Python module. Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

16 Overview Running programs Modules Importing modules Every file ending in.py is a Python module. Modules can contain attributes such as functions, Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

17 Overview Running programs Modules Importing modules Every file ending in.py is a Python module. Modules can contain attributes such as functions, We can import this module into Python: % python >>> import foo 75 ICL lecture 2 >>> foo.myname Steve Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

18 Overview Running programs Modules Executable scripts On unix/linux can make normal Python text files executable: The first line is special beginning with #! File has executable privileges (chmod +x file.py) Steve to Programming in Python (1)

19 Overview Running programs Modules Executable scripts On unix/linux can make normal Python text files executable: The first line is special beginning with #! File has executable privileges (chmod +x file.py) Example: write the following to file foo.py: #!/usr/bin/python2.4 print 25*3 # multiply by 3 print ICL + lecture 2 # concatenate strings using + myname = Steve Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

20 Overview Running programs Modules Executable scripts On unix/linux can make normal Python text files executable: The first line is special beginning with #! File has executable privileges (chmod +x file.py) Example: write the following to file foo.py: #!/usr/bin/python2.4 print 25*3 # multiply by 3 print ICL + lecture 2 # concatenate strings using + myname = Steve % chmod +x foo.py % foo.py 75 ICLlecture 2 % Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

21 Overview Running programs Modules Module reloads Importing is expensive after the first import of a module, repeated imports of a module have no effect (even if you have edited it) Use reload for force Python to rerun the file again: Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

22 Overview Running programs Modules Module reloads Importing is expensive after the first import of a module, repeated imports of a module have no effect (even if you have edited it) Use reload for force Python to rerun the file again: >>> import foo 75 ICL lecture 2 Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

23 Overview Running programs Modules Module reloads Importing is expensive after the first import of a module, repeated imports of a module have no effect (even if you have edited it) Use reload for force Python to rerun the file again: >>> import foo 75 ICL lecture 2 Redit foo.py to print 25*4 and reload >>> reload(foo) 100 ICL lecture 2 <module foo from foo.py > Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

24 Overview Running programs Modules Module attributes Consider bar.py: university = Edinburgh school = Informatics Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

25 Overview Running programs Modules Module attributes Consider bar.py: university = Edinburgh school = Informatics >>> import bar >>> print bar.school Informatics Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

26 Overview Running programs Modules Module attributes Consider bar.py: university = Edinburgh school = Informatics >>> import bar >>> print bar.school Informatics >>> from bar import school >>> print school Informatics Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

27 Overview Running programs Modules Module attributes Consider bar.py: university = Edinburgh school = Informatics >>> import bar >>> print bar.school Informatics >>> from bar import school >>> print school Informatics >>> from bar import * >>> print university Edinburgh Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

28 Overview Running programs Modules Module attributes Consider bar.py: university = Edinburgh school = Informatics >>> import bar >>> print bar.school Informatics >>> from bar import school >>> print school Informatics >>> from bar import * >>> print university Edinburgh from copies named attributes from a module, so they are variables in the recipient. Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

29 Overview Running programs Modules Python program structure Programs are composed of modules Steve to Programming in Python (1)

30 Overview Running programs Modules Python program structure Programs are composed of modules Modules contain statements Steve to Programming in Python (1)

31 Overview Running programs Modules Python program structure Programs are composed of modules Modules contain statements Statements contain expressions Steve to Programming in Python (1)

32 Overview Running programs Modules Python program structure Programs are composed of modules Modules contain statements Statements contain expressions Expressions create and process objects Steve to Programming in Python (1)

33 Overview Running programs Modules Python program structure Programs are composed of modules Modules contain statements Statements contain expressions Expressions create and process objects (Statements include: variable assignment, function calls, control flow, module access, building functions, building objects, print) (Learning Python, chapter 4) Steve to Programming in Python (1)

34 Numbers and variables Strings Lists Dictionaries Python s built-in objects 1. Numbers: integer, floating point, complex 2. Strings 3. Lists 4. Dictionaries 5. Tuples 6. Files Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

35 Numbers and variables Strings Lists Dictionaries Numbers (and variables) Usual number operators, eg: +, *, /, **, and, & Usual operator precedence: A * B + C * D = (A * B) + (C * D) (use parens for clarity and to reduce bugs) Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

36 Numbers and variables Strings Lists Dictionaries Numbers (and variables) Usual number operators, eg: +, *, /, **, and, & Usual operator precedence: A * B + C * D = (A * B) + (C * D) (use parens for clarity and to reduce bugs) Useful packages: math, random Serious users: numeric, numarray Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

37 Numbers and variables Strings Lists Dictionaries Numbers (and variables) Usual number operators, eg: +, *, /, **, and, & Usual operator precedence: A * B + C * D = (A * B) + (C * D) (use parens for clarity and to reduce bugs) Useful packages: math, random Serious users: numeric, numarray Variables created when first assigned a value replaced with their values when used in expressions must be assigned before use no need to declare ahead of time Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

38 Numbers and variables Strings Lists Dictionaries Strings String handling in Python is easy and powerful (unlike C, C++, Java) (Learning Python, chapter 5) Steve to Programming in Python (1)

39 Numbers and variables Strings Lists Dictionaries Strings String handling in Python is easy and powerful (unlike C, C++, Java) Strings may be written using single quotes: This is a Python string or double quotes "and so is this" (Learning Python, chapter 5) Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

40 Numbers and variables Strings Lists Dictionaries Strings String handling in Python is easy and powerful (unlike C, C++, Java) Strings may be written using single quotes: This is a Python string or double quotes "and so is this" They are the same, it just makes it easy to include single (double) quotes: He said "what?", "He s here" (Learning Python, chapter 5) Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

41 Numbers and variables Strings Lists Dictionaries Backslash in strings Backslash \ can be used to escape (protect) certain non-printing or special characters \n is newline, \t is tab Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

42 Numbers and variables Strings Lists Dictionaries Backslash in strings Backslash \ can be used to escape (protect) certain non-printing or special characters \n is newline, \t is tab >>> s = Name\tAge\nJohn\t21\nBob\t44 >>> print s Name Age John 21 Bob 44 >>> t = "Mary\ s" >>> print t "Mary s" Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

43 Numbers and variables Strings Lists Dictionaries Triple quote Use a triple quote (""" or ) for a string over several lines: >>> s = """this is... a string... over 3 lines""" >>> t = so... is... this >>> print s this is a string over 3 lines >>> print t so is this Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

44 Numbers and variables Strings Lists Dictionaries String operations Concatenation (+) Length (len) Repetition (*) Indexing and slicing ([]) Steve to Programming in Python (1)

45 Numbers and variables Strings Lists Dictionaries String operations Concatenation (+) Length (len) Repetition (*) Indexing and slicing ([]) s = computational t = linguistics cl = s + + t # computational linguistics l = len(cl) # 25 u = - * 6 # c = s[3] # p x = cl[11:16] # al li y = cl[20:] # stics z = cl[:-1] # computational linguistic Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

46 Numbers and variables Strings Lists Dictionaries String methods Methods are functions applied associated with objects String methods allow strings to be processed in a more sophisticated way Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

47 Numbers and variables Strings Lists Dictionaries String methods Methods are functions applied associated with objects String methods allow strings to be processed in a more sophisticated way s = example s = s.capitalize() # Example t = s.lower() # example flag = s.isalpha() # True s = s.replace( amp, M ) # exmle i = t.find( xa ) # 1 n = t.count( e ) # 2 Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

48 Numbers and variables Strings Lists Dictionaries Lists in Python Ordered collections of arbitrary objects Accessed by indexing based on offset Variable length, heterogenous (can contain any type of object), nestable Mutable (can change the elements, unlike strings) Steve to Programming in Python (1)

49 Numbers and variables Strings Lists Dictionaries Lists in Python Ordered collections of arbitrary objects Accessed by indexing based on offset Variable length, heterogenous (can contain any type of object), nestable Mutable (can change the elements, unlike strings) >>> s = [ a, b, c ] >>> t = [1, 2, 3] >>> u = s + t # [ a, b, c, 1, 2, 3] >>> n = len(u) # 6 >>> for x in s:... print x... a b c Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

50 Numbers and variables Strings Lists Dictionaries Indexing and slicing lists Indexing and slicing work like strings Indexing returns the object element Slicing returns a list Can use indexing and slicing to change contents Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

51 Numbers and variables Strings Lists Dictionaries Indexing and slicing lists Indexing and slicing work like strings Indexing returns the object element Slicing returns a list Can use indexing and slicing to change contents l = [ a, b, c, d ] x = l[2] # c m = l[1:] # [ b, c, d ] l[2] = z # [ a, b, z, d ] l[0:2] = [ x, y ] # [ x, y, z, d ] (Learning Python, chapter 6) Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

52 Numbers and variables Strings Lists Dictionaries List methods Lists also have some useful methods append adds an item to the list extend adds multiple items sort orders a list in place Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

53 Numbers and variables Strings Lists Dictionaries List methods Lists also have some useful methods append adds an item to the list extend adds multiple items sort orders a list in place l = [ x, y, z, d ] l.sort() # [ d, x, y, z ] l.append( q ) # [ d, x, y, z, q ] l.extend([ r, s ]) # [ d, x, y, z, q, r, s ] l.append([ v, w ]) # [ d, x, y, z, q, r, s, [ v, w ]] Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

54 Numbers and variables Strings Lists Dictionaries Dictionaries Dictionaries are Addressed by key, not by offset Unordered collections of arbitrary objects Variable length, heterogenous (can contain any type of object), nestable Mutable (can change the elements, unlike strings) Steve to Programming in Python (1)

55 Numbers and variables Strings Lists Dictionaries Dictionaries Dictionaries are Addressed by key, not by offset Unordered collections of arbitrary objects Variable length, heterogenous (can contain any type of object), nestable Mutable (can change the elements, unlike strings) Think of dictionaries as a set of key:value pairs Use a key to access its value (Learning Python, chapter 7) Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

56 Numbers and variables Strings Lists Dictionaries Dictionary example level = { icl : 9, nlssd : 11, inf2b : 8} x = level[ nlssd ] # 11 n = len(level) # 3 flag = level.has key( inf2b ) # True l = level.keys() # [ nlssd, inf2b, icl ] level[ dil ] = 11 # { dil : 11, nlssd : 11, inf2b : 8, icl : 9} level[ icl ] = 10 # { dil : 11, nlssd : 11, inf2b : 8, icl : 10} l = level.items() # [( dil, 11), ( nlssd, 11), ( inf2b, 8), ( icl, 10)] l = level.values() # [11, 11, 8, 10] Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

57 Numbers and variables Strings Lists Dictionaries Notes on dictionaries Sequence operations don t work: dictionaries are mappings, not sequences Dictionaries have a set of keys: only one value per key Assigning to a new key adds an entry Keys can be any immutable object, not just strings Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

58 Numbers and variables Strings Lists Dictionaries Notes on dictionaries Sequence operations don t work: dictionaries are mappings, not sequences Dictionaries have a set of keys: only one value per key Assigning to a new key adds an entry Keys can be any immutable object, not just strings Dictionaries can be used as records Dictionaries can be used for sparse matrices Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

59 Numbers and variables Strings Lists Dictionaries Other objects Tuples: like lists, but immutable (cannot be changed) Steve to Programming in Python (1)

60 Numbers and variables Strings Lists Dictionaries Other objects Tuples: like lists, but immutable (cannot be changed) emptyt = () T1 = (1, 2, 3) x = T1[1] n = len(t1) Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

61 Numbers and variables Strings Lists Dictionaries Other objects Tuples: like lists, but immutable (cannot be changed) emptyt = () T1 = (1, 2, 3) x = T1[1] n = len(t1) Files: objects with methods for reading and writing to files Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

62 Numbers and variables Strings Lists Dictionaries Other objects Tuples: like lists, but immutable (cannot be changed) emptyt = () T1 = (1, 2, 3) x = T1[1] n = len(t1) Files: objects with methods for reading and writing to files fil = open( myfile, w ) fil.write( hello file\n ) fil.close() Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

63 Numbers and variables Strings Lists Dictionaries Other objects Tuples: like lists, but immutable (cannot be changed) emptyt = () T1 = (1, 2, 3) x = T1[1] n = len(t1) Files: objects with methods for reading and writing to files fil = open( myfile, w ) fil.write( hello file\n ) fil.close() f2 = open( myfile, r ) s = f2.readline() # hello file\n t = f2.readline() # (Learning Python, chapter 7) Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

64 Conditionals Loops if tests course = icl if course == icl : print Ewan / Steve elif course == dil : print Phillip else: print Someone else Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

65 Conditionals Loops if tests course = icl if course == icl : print Ewan / Steve elif course == dil : print Phillip else: print Someone else Indentation determines the block structure Indentation to the left is the only place where whitespace matters in Python Indentation enforces readability Tests after if and elif can be anything that returns True/False (Learning Python, chapter 9) Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

66 Conditionals Loops while loops A while loop keeps iterating while the test at the top remains True. a = 0 b = 10 while a < b: print a a = a + 1 Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

67 Conditionals Loops while loops A while loop keeps iterating while the test at the top remains True. a = 0 b = 10 while a < b: print a a = a + 1 s = icl while len(s) > 0: print s s = s[1:] (Learning Python, chapter 10) Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

68 Conditionals Loops for loops for is used to step through any sequence object l = [ a, b, c ] for i in l: print i Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

69 Conditionals Loops for loops for is used to step through any sequence object l = [ a, b, c ] for i in l: print i sum = 0 for x in [1, 2, 3, 4, 5, 6]: sum = sum + x print sum Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

70 Conditionals Loops for loops for is used to step through any sequence object l = [ a, b, c ] for i in l: print i sum = 0 for x in [1, 2, 3, 4, 5, 6]: sum = sum + x print sum range() is a useful function: range(5) = [0, 1, 2, 3, 4] range(2, 5) = [2, 3, 4] range(0, 6, 2) = [0, 2, 4] Steve Renalss.renals@ed.ac.uk to Programming in Python (1)

71 to Python Python programs and modules Basic objects: numbers, strings, lists, dictionaries Control flow: if, while, for Steve to Programming in Python (1)

Introduction to Programming in Python (2)

Introduction to Programming in Python (2) Introduction to Programming in Python (2) Steve Renals s.renals@ed.ac.uk ICL 29 September 2005 Conditionals Loops Function basics Variables and functions Functional programming Designing functions Python

More information

Introduction to Python Lecture #3

Introduction to Python Lecture #3 Introduction to Python Lecture #3 Computational Linguistics CMPSCI 591N, Spring 2006 University of Massachusetts Amherst Andrew McCallum Today s Main Points Check in on HW#1. Demo. Intro to Python computer

More information

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes GIS 4653/5653: Spatial Programming and GIS More Python: Statements, Types, Functions, Modules, Classes Statement Syntax The if-elif-else statement Indentation and and colons are important Parentheses and

More information

Al al-bayt University Prince Hussein Bin Abdullah College for Information Technology Computer Science Department

Al al-bayt University Prince Hussein Bin Abdullah College for Information Technology Computer Science Department Al al-bayt University Prince Hussein Bin Abdullah College for Information Technology Computer Science Department 0901212 Python Programming 1 st Semester 2014/2015 Course Catalog This course introduces

More information

Python I. Some material adapted from Upenn cmpe391 slides and other sources

Python I. Some material adapted from Upenn cmpe391 slides and other sources Python I Some material adapted from Upenn cmpe391 slides and other sources Overview Names & Assignment Data types Sequences types: Lists, Tuples, and Strings Mutability Understanding Reference Semantics

More information

Introduction to Python

Introduction to Python Introduction to Python EECS 4415 Big Data Systems Tilemachos Pechlivanoglou tipech@eecs.yorku.ca 2 Background Why Python? "Scripting language" Very easy to learn Interactive front-end for C/C++ code Object-oriented

More information

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines. Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

The current topic: Python. Announcements. Python. Python

The current topic: Python. Announcements. Python. Python The current topic: Python Announcements! Introduction! reasons for studying languages! language classifications! simple syntax specification Object-oriented programming: Python Types and values Syntax

More information

ECE 364 Software Engineering Tools Lab. Lecture 3 Python: Introduction

ECE 364 Software Engineering Tools Lab. Lecture 3 Python: Introduction ECE 364 Software Engineering Tools Lab Lecture 3 Python: Introduction 1 Introduction to Python Common Data Types If Statements For and While Loops Basic I/O Lecture Summary 2 What is Python? Python is

More information

Flow Control: Branches and loops

Flow Control: Branches and loops Flow Control: Branches and loops In this context flow control refers to controlling the flow of the execution of your program that is, which instructions will get carried out and in what order. In the

More information

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops PRG PROGRAMMING ESSENTIALS 1 Lecture 2 Program flow, Conditionals, Loops https://cw.fel.cvut.cz/wiki/courses/be5b33prg/start Michal Reinštein Czech Technical University in Prague, Faculty of Electrical

More information

Lists, Tuples and Dictionaries. HORT Lecture 10 Instructor: Kranthi Varala

Lists, Tuples and Dictionaries. HORT Lecture 10 Instructor: Kranthi Varala Lists, Tuples and Dictionaries HORT 59000 Lecture 10 Instructor: Kranthi Varala Core data types Numbers Strings Lists Dictionaries Tuples Files Sets References and dynamic typing Dynamic typing allows

More information

CS 3813/718 Fall Python Programming. Professor Liang Huang.

CS 3813/718 Fall Python Programming. Professor Liang Huang. CS 3813/718 Fall 2012 Python Programming Professor Liang Huang huang@cs.qc.cuny.edu http://vision.cs.qc.cuny.edu/huang/python-2012f/ Logistics Lectures: TTh 9:25-10:40 am SB B-141 Personnel Instructor

More information

Some material adapted from Upenn cmpe391 slides and other sources

Some material adapted from Upenn cmpe391 slides and other sources Some material adapted from Upenn cmpe391 slides and other sources History Installing & Running Python Names & Assignment Sequences types: Lists, Tuples, and Strings Mutability Understanding Reference Semantics

More information

ENGR 102 Engineering Lab I - Computation

ENGR 102 Engineering Lab I - Computation ENGR 102 Engineering Lab I - Computation Learning Objectives by Week 1 ENGR 102 Engineering Lab I Computation 2 Credits 2. Introduction to the design and development of computer applications for engineers;

More information

Python Class-Lesson1 Instructor: Yao

Python Class-Lesson1 Instructor: Yao Python Class-Lesson1 Instructor: Yao What is Python? Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined

More information

Course Introduction and Python Basics

Course Introduction and Python Basics Course Introduction and Python Basics Johan Falkenjack 2018-01-15 Course Introduction Python > Data Science 3 hp pass/fail 3 lectures, 3 labs (2 sessions for each lab) Python Basics Programming Paradigms

More information

Lecture 7: Python s Built-in. in Types and Basic Statements

Lecture 7: Python s Built-in. in Types and Basic Statements The University of North Carolina at Chapel Hill Spring 2002 Lecture 7: Python s Built-in in Types and Basic Statements Jan 25 1 Built-in in Data Structures: Lists A list is an ordered collection of objects

More information

Senthil Kumaran S

Senthil Kumaran S Senthil Kumaran S http://www.stylesen.org/ Agenda History Basics Control Flow Functions Modules History What is Python? Python is a general purpose, object-oriented, high level, interpreted language Created

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

Python - Variable Types. John R. Woodward

Python - Variable Types. John R. Woodward Python - Variable Types John R. Woodward Variables 1. Variables are nothing but named reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.

More information

A Brief Python Tutorial

A Brief Python Tutorial Sven H. Chilton University of California - Berkeley LBL Heavy Ion Fusion Group Talk 16 August, 2007 Sven Chilton, 2007 1 Outline Why Use Python? Running Python Types and Operators Basic Statements Functions

More information

Introduction to: Computers & Programming: Review prior to 1 st Midterm

Introduction to: Computers & Programming: Review prior to 1 st Midterm Introduction to: Computers & Programming: Review prior to 1 st Midterm Adam Meyers New York University Summary Some Procedural Matters Summary of what you need to Know For the Test and To Go Further in

More information

Part III Appendices 165

Part III Appendices 165 Part III Appendices 165 Appendix A Technical Instructions Learning Outcomes This material will help you learn how to use the software you need to do your work in this course. You won t be tested on it.

More information

BCH339N Systems Biology/Bioinformatics Spring 2018 Marcotte A Python programming primer

BCH339N Systems Biology/Bioinformatics Spring 2018 Marcotte A Python programming primer BCH339N Systems Biology/Bioinformatics Spring 2018 Marcotte A Python programming primer Python: named after Monty Python s Flying Circus (designed to be fun to use) Python documentation: http://www.python.org/doc/

More information

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D 1/60 Interactive use $ python Python 2.7.5 (default, Mar 9 2014, 22:15:05) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information.

More information

Python Basics. Lecture and Lab 5 Day Course. Python Basics

Python Basics. Lecture and Lab 5 Day Course. Python Basics Python Basics Lecture and Lab 5 Day Course Course Overview Python, is an interpreted, object-oriented, high-level language that can get work done in a hurry. A tool that can improve all professionals ability

More information

CS Advanced Unix Tools & Scripting

CS Advanced Unix Tools & Scripting & Scripting Spring 2011 Hussam Abu-Libdeh slides by David Slater March 4, 2011 Hussam Abu-Libdeh slides by David Slater & Scripting Python An open source programming language conceived in the late 1980s.

More information

History Installing & Running Python Names & Assignment Sequences types: Lists, Tuples, and Strings Mutability

History Installing & Running Python Names & Assignment Sequences types: Lists, Tuples, and Strings Mutability History Installing & Running Python Names & Assignment Sequences types: Lists, Tuples, and Strings Mutability Some material adapted from Upenn cmpe391 slides and other sources Invented in the Netherlands,

More information

PROGRAMMING FUNDAMENTALS

PROGRAMMING FUNDAMENTALS PROGRAMMING FUNDAMENTALS VARIABLES, EXPRESSIONS AND STATEMENTS João Correia Lopes INESC TEC, FEUP 27 September 2018 FPRO/MIEIC/2018-19 27/09/2018 1 / 21 INTRODUCTION GOALS By the end of this class, the

More information

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s Intro to Python Python Getting increasingly more common Designed to have intuitive and lightweight syntax In this class, we will be using Python 3.x Python 2.x is still very popular, and the differences

More information

CPSC 217 Midterm (Python 3 version)

CPSC 217 Midterm (Python 3 version) CPSC 217 Midterm (Python 3 version) Duration: 60 minutes 7 March 2011 This exam has 81 questions and 14 pages. This exam is closed book. No notes, books, calculators or electronic devices, or other assistance

More information

6. Data Types and Dynamic Typing (Cont.)

6. Data Types and Dynamic Typing (Cont.) 6. Data Types and Dynamic Typing (Cont.) 6.5 Strings Strings can be delimited by a pair of single quotes ('...'), double quotes ("..."), triple single quotes ('''...'''), or triple double quotes ("""...""").

More information

Introduction to Python

Introduction to Python Introduction to Python خانه ریاضیات اصفهان فرزانه کاظمی زمستان 93 1 Why Python? Python is free. Python easy to lean and use. Reduce time and length of coding. Huge standard library Simple (Python code

More information

Data type built into Python. Dictionaries are sometimes found in other languages as associative memories or associative arrays.

Data type built into Python. Dictionaries are sometimes found in other languages as associative memories or associative arrays. NETB 329 Lecture 4 Data Structures in Python Dictionaries Data type built into Python. Dictionaries are sometimes found in other languages as associative memories or associative arrays. 1 of 70 Unlike

More information

Practical Workbook Computer Programming

Practical Workbook Computer Programming Practical Workbook Computer Programming Name Year Batch Roll No Department: 5 th Edition Fall 2017-2018 Dept. of Computer & Information Systems Engineering NED University of Engineering & Technology, Karachi

More information

CS61A Lecture 16. Amir Kamil UC Berkeley February 27, 2013

CS61A Lecture 16. Amir Kamil UC Berkeley February 27, 2013 CS61A Lecture 16 Amir Kamil UC Berkeley February 27, 2013 Announcements HW5 due tonight Trends project due on Tuesday Partners are required; find one in lab or on Piazza Will not work in IDLE New bug submission

More information

All programs can be represented in terms of sequence, selection and iteration.

All programs can be represented in terms of sequence, selection and iteration. Python Lesson 3 Lists, for loops and while loops Suffolk One, Ipswich, 4:30 to 6:00 Tuesday Jan 28 Nicky Hughes All programs can be represented in terms of sequence, selection and iteration. 1 Computational

More information

Python. Jae-Gil Lee Based on the slides by K. Naik, M. Raju, and S. Bhatkar. December 28, Outline

Python. Jae-Gil Lee Based on the slides by K. Naik, M. Raju, and S. Bhatkar. December 28, Outline Python Jae-Gil Lee Based on the slides by K. Naik, M. Raju, and S. Bhatkar December 28, 2011 1 Outline Introduction Installation and Use Distinct Features Python Basics Functional Example Comparisons with

More information

COMP519 Web Programming Lecture 17: Python (Part 1) Handouts

COMP519 Web Programming Lecture 17: Python (Part 1) Handouts COMP519 Web Programming Lecture 17: Python (Part 1) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool Contents

More information

Python: Short Overview and Recap

Python: Short Overview and Recap Python: Short Overview and Recap Benjamin Roth CIS LMU Benjamin Roth (CIS LMU) Python: Short Overview and Recap 1 / 39 Data Types Object type Example creation Numbers (int, float) 123, 3.14 Strings this

More information

Python Language Basics I. Georgia Advanced Computing Resource Center University of Georgia Zhuofei Hou, HPC Trainer

Python Language Basics I. Georgia Advanced Computing Resource Center University of Georgia Zhuofei Hou, HPC Trainer Python Language Basics I Georgia Advanced Computing Resource Center University of Georgia Zhuofei Hou, HPC Trainer zhuofei@uga.edu 1 Outline What is GACRC? Hello, Python! General Lexical Conventions Basic

More information

CS61A Lecture 16. Amir Kamil UC Berkeley February 27, 2013

CS61A Lecture 16. Amir Kamil UC Berkeley February 27, 2013 CS61A Lecture 16 Amir Kamil UC Berkeley February 27, 2013 Announcements HW5 due tonight Trends project due on Tuesday Partners are required; find one in lab or on Piazza Will not work in IDLE New bug submission

More information

TUGCE KEMEROZ - ASLI OZKAN - AYSE TARTAN. Week 12/02/ /02/2007 Lecture Notes:

TUGCE KEMEROZ - ASLI OZKAN - AYSE TARTAN. Week 12/02/ /02/2007 Lecture Notes: 1 INSTRUCTOR: FAZLI CAN TUGCE KEMEROZ - ASLI OZKAN - AYSE TARTAN Week 12/02/2007-16/02/2007 Lecture Notes: When we write a program we must design our programs to take correct output. For correct output,

More information

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D 1/58 Interactive use $ python Python 2.7.5 (default, Mar 9 2014, 22:15:05) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information.

More information

Introduction to Bioinformatics

Introduction to Bioinformatics Introduction to Bioinformatics Variables, Data Types, Data Structures, Control Structures Janyl Jumadinova February 3, 2016 Data Type Data types are the basic unit of information storage. Instances of

More information

Glossary. For Introduction to Programming Using Python By Y. Daniel Liang

Glossary. For Introduction to Programming Using Python By Y. Daniel Liang Chapter 1 Glossary For Introduction to Programming Using Python By Y. Daniel Liang.py Python script file extension name. assembler A software used to translate assemblylanguage programs into machine code.

More information

CS2304: Python for Java Programmers. CS2304: Sequences and Collections

CS2304: Python for Java Programmers. CS2304: Sequences and Collections CS2304: Sequences and Collections Sequences In Python A sequence type in python supports: The in membership operator. The len() function. Slicing like we saw with strings, s[1:3]. And is iterable (for

More information

CSCE 110 Programming I Basics of Python: Variables, Expressions, Input/Output

CSCE 110 Programming I Basics of Python: Variables, Expressions, Input/Output CSCE 110 Programming I Basics of Python: Variables, Expressions, Input/Output Dr. Tiffani L. Williams Department of Computer Science and Engineering Texas A&M University Spring 2011 Python Python was developed

More information

Python: common syntax

Python: common syntax Lab 09 Python! Python Intro Main Differences from C++: True and False are capitals Python floors (always down) with int division (matters with negatives): -3 / 2 = -2 No variable data types or variable

More information

18.1. CS 102 Unit 18. Python. Mark Redekopp

18.1. CS 102 Unit 18. Python. Mark Redekopp 18.1 CS 102 Unit 18 Python Mark Redekopp 18.2 Credits Many of the examples below are taken from the online Python tutorial at: http://docs.python.org/tutorial/introduction.html 18.3 Python in Context Two

More information

COMP1730/COMP6730 Programming for Scientists. Strings

COMP1730/COMP6730 Programming for Scientists. Strings COMP1730/COMP6730 Programming for Scientists Strings Lecture outline * Sequence Data Types * Character encoding & strings * Indexing & slicing * Iteration over sequences Sequences * A sequence contains

More information

PYTHON CONTENT NOTE: Almost every task is explained with an example

PYTHON CONTENT NOTE: Almost every task is explained with an example PYTHON CONTENT NOTE: Almost every task is explained with an example Introduction: 1. What is a script and program? 2. Difference between scripting and programming languages? 3. What is Python? 4. Characteristics

More information

Python Tutorial. CSE 3461: Computer Networking

Python Tutorial. CSE 3461: Computer Networking Python Tutorial CSE 3461: Computer Networking 1 Outline Introduction to Python CSE Environment Tips for Python Primitive Types Tips for Encoding/Decoding an IP Address 2 Intro to Python Dynamically typed,

More information

Python a modern scripting PL. Python

Python a modern scripting PL. Python Python a modern scripting PL Basic statements Basic data types & their operations Strings, lists, tuples, dictionaries, files Functions Strings Dictionaries Many examples originally from O Reilly Learning

More information

PROGRAMMING FUNDAMENTALS

PROGRAMMING FUNDAMENTALS PROGRAMMING FUNDAMENTALS INTRODUCTION & THE WAY OF THE PROGRAM João Correia Lopes INESC TEC, FEUP 25 September 2018 FPRO/MIEIC/2018-19 25/09/2018 1 / 33 INTRODUCTION GOALS By the end of this class, the

More information

A Python programming primer for biochemists. BCH364C/394P Systems Biology/Bioinformatics Edward Marcotte, Univ of Texas at Austin

A Python programming primer for biochemists. BCH364C/394P Systems Biology/Bioinformatics Edward Marcotte, Univ of Texas at Austin A Python programming primer for biochemists (Named after Monty Python s Flying Circus& designed to be fun to use) BCH364C/394P Systems Biology/Bioinformatics Edward Marcotte, Univ of Texas at Austin Science

More information

CS S-02 Python 1. Most python references use examples involving spam, parrots (deceased), silly walks, and the like

CS S-02 Python 1. Most python references use examples involving spam, parrots (deceased), silly walks, and the like CS662-2013S-02 Python 1 02-0: Python Name python comes from Monte Python s Flying Circus Most python references use examples involving spam, parrots (deceased), silly walks, and the like Interpreted language

More information

Introduction to Python

Introduction to Python Introduction to Python Reading assignment: Perkovic text, Ch. 1 and 2.1-2.5 Python Python is an interactive language. Java or C++: compile, run Also, a main function or method Python: type expressions

More information

CSE : Python Programming

CSE : Python Programming CSE 399-004: Python Programming Lecture 2: Data, Classes, and Modules January 22, 2007 http://www.seas.upenn.edu/~cse39904/ Administrative things Teaching assistant Brian Summa (bsumma @ seas.upenn.edu)

More information

What Version Number to Install

What Version Number to Install A Python Primer This chapter provides a quick overview of the Python language. The goal in this chapter is not to teach you the Python language excellent books have been written on that subject, such as

More information

AI Programming CS S-02 Python

AI Programming CS S-02 Python AI Programming CS662-2013S-02 Python David Galles Department of Computer Science University of San Francisco 02-0: Python Name python comes from Monte Python s Flying Circus Most python references use

More information

The Dynamic Typing Interlude

The Dynamic Typing Interlude CHAPTER 6 The Dynamic Typing Interlude In the prior chapter, we began exploring Python s core object types in depth with a look at Python numbers. We ll resume our object type tour in the next chapter,

More information

Introduction to Python! Lecture 2

Introduction to Python! Lecture 2 .. Introduction to Python Lecture 2 Summary Summary: Lists Sets Tuples Variables while loop for loop Functions Names and values Passing parameters to functions Lists Characteristics of the Python lists

More information

CS Summer 2013

CS Summer 2013 CS 1110 - Summer 2013 intro to programming -- how to think like a robot :) we use the Python* language (www.python.org) programming environments (many choices): Eclipse (free from www.eclipse.org), or

More information

Python Crash-Course. C. Basso. Dipartimento di Informatica e Scienze dell Informazione Università di Genova. December 11, 2007

Python Crash-Course. C. Basso. Dipartimento di Informatica e Scienze dell Informazione Università di Genova. December 11, 2007 Python Crash-Course C. Basso Dipartimento di Informatica e Scienze dell Informazione Università di Genova December 11, 2007 Basso (DISI) Python Crash-Course December 11, 2007 1 / 26 What is Python? Python

More information

Exam 1 Format, Concepts, What you should be able to do, and Sample Problems

Exam 1 Format, Concepts, What you should be able to do, and Sample Problems CSSE 120 Introduction to Software Development Exam 1 Format, Concepts, What you should be able to do, and Sample Problems Page 1 of 6 Format: The exam will have two sections: Part 1: Paper-and-Pencil o

More information

Accelerating Information Technology Innovation

Accelerating Information Technology Innovation Accelerating Information Technology Innovation http://aiti.mit.edu/program/philippines-summer-2012/ Philippines Summer 2012 Lecture 1 Introduction to Python June 19, 2012 Agenda About the Course What is

More information

EE 355 Unit 17. Python. Mark Redekopp

EE 355 Unit 17. Python. Mark Redekopp 1 EE 355 Unit 17 Python Mark Redekopp 2 Credits Many of the examples below are taken from the online Python tutorial at: http://docs.python.org/tutorial/introduction.html 3 Python in Context Interpreted,

More information

Numerical Methods. Centre for Mathematical Sciences Lund University. Spring 2015

Numerical Methods. Centre for Mathematical Sciences Lund University. Spring 2015 Numerical Methods Claus Führer Alexandros Sopasakis Centre for Mathematical Sciences Lund University Spring 2015 Preface These notes serve as a skeleton for the course. They document together with the

More information

1. BASICS OF PYTHON. JHU Physics & Astronomy Python Workshop Lecturer: Mubdi Rahman

1. BASICS OF PYTHON. JHU Physics & Astronomy Python Workshop Lecturer: Mubdi Rahman 1. BASICS OF PYTHON JHU Physics & Astronomy Python Workshop 2017 Lecturer: Mubdi Rahman HOW IS THIS WORKSHOP GOING TO WORK? We will be going over all the basics you need to get started and get productive

More information

Data Structures. Lists, Tuples, Sets, Dictionaries

Data Structures. Lists, Tuples, Sets, Dictionaries Data Structures Lists, Tuples, Sets, Dictionaries Collections Programs work with simple values: integers, floats, booleans, strings Often, however, we need to work with collections of values (customers,

More information

Python Training. Complete Practical & Real-time Trainings. A Unit of SequelGate Innovative Technologies Pvt. Ltd.

Python Training. Complete Practical & Real-time Trainings. A Unit of SequelGate Innovative Technologies Pvt. Ltd. Python Training Complete Practical & Real-time Trainings A Unit of. ISO Certified Training Institute Microsoft Certified Partner Training Highlights : Complete Practical and Real-time Scenarios Session

More information

Python Tutorial. Day 1

Python Tutorial. Day 1 Python Tutorial Day 1 1 Why Python high level language interpreted and interactive real data structures (structures, objects) object oriented all the way down rich library support 2 The First Program #!/usr/bin/env

More information

Professor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators

Professor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators 1 Professor: Sana Odeh odeh@courant.nyu.edu Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators Review What s wrong with this line of code? print( He said Hello ) What s wrong with

More information

Webgurukul Programming Language Course

Webgurukul Programming Language Course Webgurukul Programming Language Course Take One step towards IT profession with us Python Syllabus Python Training Overview > What are the Python Course Pre-requisites > Objectives of the Course > Who

More information

Introduction to Python

Introduction to Python Introduction to Python Version 1.1.5 (12/29/2008) [CG] Page 1 of 243 Introduction...6 About Python...7 The Python Interpreter...9 Exercises...11 Python Compilation...12 Python Scripts in Linux/Unix & Windows...14

More information

Basic Scripting, Syntax, and Data Types in Python. Mteor 227 Fall 2017

Basic Scripting, Syntax, and Data Types in Python. Mteor 227 Fall 2017 Basic Scripting, Syntax, and Data Types in Python Mteor 227 Fall 2017 Basic Shell Scripting/Programming with Python Shell: a user interface for access to an operating system s services. The outer layer

More information

Advanced Python. Executive Summary, Session 1

Advanced Python. Executive Summary, Session 1 Advanced Python Executive Summary, Session 1 OBJECT: a unit of data of a particular type with characteristic functionality (i.e., methods and/or use with operators). Everything in Python is an object.

More information

Working with Lists 4

Working with Lists 4 CS 61A Lecture 10 Announcements Lists ['Demo'] Working with Lists 4 Working with Lists >>> digits = [1, 8, 2, 8] 4 Working with Lists >>> digits = [1, 8, 2, 8] >>> digits = [2//2, 2+2+2+2, 2, 2*2*2] 4

More information

The Practice of Computing Using PYTHON. Chapter 4. Working with Strings. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

The Practice of Computing Using PYTHON. Chapter 4. Working with Strings. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley The Practice of Computing Using PYTHON William Punch Richard Enbody Chapter 4 Working with Strings 1 Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Sequence of Characters We

More information

Physics 514 Basic Python Intro

Physics 514 Basic Python Intro Physics 514 Basic Python Intro Emanuel Gull September 8, 2014 1 Python Introduction Download and install python. On Linux this will be done with apt-get, evince, portage, yast, or any other package manager.

More information

Scripting Languages. Python basics

Scripting Languages. Python basics Scripting Languages Python basics Interpreter Session: python Direct conversation with python (>>>) Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright",

More information

STA141C: Big Data & High Performance Statistical Computing

STA141C: Big Data & High Performance Statistical Computing STA141C: Big Data & High Performance Statistical Computing Lecture 1: Python programming (1) Cho-Jui Hsieh UC Davis April 4, 2017 Python Python is a scripting language: Non-scripting language (C++. java):

More information

UNIVERSITÀ DI PADOVA. < 2014 March >

UNIVERSITÀ DI PADOVA. < 2014 March > UNIVERSITÀ DI PADOVA < 2014 March > Easy-to-learn: Python has relatively few keywords, simple structure, and a clearly defined syntax. Easy-to-read: Python code is much more clearly defined and visible

More information

Teaching London Computing

Teaching London Computing Teaching London Computing A Level Computer Science Topic 3: Advanced Programming in Python William Marsh School of Electronic Engineering and Computer Science Queen Mary University of London Aims Further

More information

Python Workshop. January 18, Chaitanya Talnikar. Saket Choudhary

Python Workshop. January 18, Chaitanya Talnikar. Saket Choudhary Chaitanya Talnikar Saket Choudhary January 18, 2012 Python Named after this : Python Slide 1 was a joke! Python Slide 1 was a joke! Python : Conceived in late 1980s by Guido van Rossum as a successor to

More information

ENGR 102 Engineering Lab I - Computation

ENGR 102 Engineering Lab I - Computation ENGR 102 Engineering Lab I - Computation Week 07: Arrays and Lists of Data Introduction to Arrays In last week s lecture, 1 we were introduced to the mathematical concept of an array through the equation

More information

Functions, Scope & Arguments. HORT Lecture 12 Instructor: Kranthi Varala

Functions, Scope & Arguments. HORT Lecture 12 Instructor: Kranthi Varala Functions, Scope & Arguments HORT 59000 Lecture 12 Instructor: Kranthi Varala Functions Functions are logical groupings of statements to achieve a task. For example, a function to calculate the average

More information

Python in 10 (50) minutes

Python in 10 (50) minutes Python in 10 (50) minutes https://www.stavros.io/tutorials/python/ Python for Microcontrollers Getting started with MicroPython Donald Norris, McGrawHill (2017) Python is strongly typed (i.e. types are

More information

Working with Strings. Husni. "The Practice of Computing Using Python", Punch & Enbody, Copyright 2013 Pearson Education, Inc.

Working with Strings. Husni. The Practice of Computing Using Python, Punch & Enbody, Copyright 2013 Pearson Education, Inc. Working with Strings Husni "The Practice of Computing Using Python", Punch & Enbody, Copyright 2013 Pearson Education, Inc. Sequence of characters We've talked about strings being a sequence of characters.

More information

The Pyth Language. Administrivia

The Pyth Language. Administrivia Administrivia The Pyth Language Lecture 5 Please make sure you have registered your team, created SSH keys as indicated on the admin page, and also have electronically registered with us as well. Prof.

More information

ECE 364 Software Engineering Tools Laboratory. Lecture 4 Python: Collections I

ECE 364 Software Engineering Tools Laboratory. Lecture 4 Python: Collections I ECE 364 Software Engineering Tools Laboratory Lecture 4 Python: Collections I 1 Lecture Summary Lists Tuples Sets Dictionaries Printing, More I/O Bitwise Operations 2 Lists list is a built-in Python data

More information

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02 Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02 Hello, in this lecture we will learn about some fundamentals concepts of java.

More information

Introduction to Python: Data types. HORT Lecture 8 Instructor: Kranthi Varala

Introduction to Python: Data types. HORT Lecture 8 Instructor: Kranthi Varala Introduction to Python: Data types HORT 59000 Lecture 8 Instructor: Kranthi Varala Why Python? Readability and ease-of-maintenance Python focuses on well-structured easy to read code Easier to understand

More information

Sequence of Characters. Non-printing Characters. And Then There Is """ """ Subset of UTF-8. String Representation 6/5/2018.

Sequence of Characters. Non-printing Characters. And Then There Is   Subset of UTF-8. String Representation 6/5/2018. Chapter 4 Working with Strings Sequence of Characters we've talked about strings being a sequence of characters. a string is indicated between ' ' or " " the exact sequence of characters is maintained

More information

Course Outline - COMP150. Lectures and Labs

Course Outline - COMP150. Lectures and Labs Course Outline - COMP150 Lectures and Labs 1 The way of the program 1.1 The Python programming language 1.2 What is a program? 1.3 What is debugging? 1.4 Experimental debugging 1.5 Formal and natural languages

More information

Introduction to Python Code Quality

Introduction to Python Code Quality Introduction to Python Code Quality Clarity and readability are important (easter egg: type import this at the Python prompt), as well as extensibility, meaning code that can be easily enhanced and extended.

More information

Introduction to Python - Part I CNV Lab

Introduction to Python - Part I CNV Lab Introduction to Python - Part I CNV Lab Paolo Besana 22-26 January 2007 This quick overview of Python is a reduced and altered version of the online tutorial written by Guido Van Rossum (the creator of

More information