CSC326 Lecture 2 - CSC326 Python Imperative Core (Lec 2)...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
CSC326 Python Imperative Core (Lec 2) i CSC326 Python Imperative Core (Lec 2)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CSC326 Python Imperative Core (Lec 2) ii REVISION HISTORY NUMBER DATE DESCRIPTION NAME 1.0 2011-09 JZ
Background image of page 2
CSC326 Python Imperative Core (Lec 2) iii Contents 1 Agenda 1 2 Invoking Python 1 3 Value, Type, Variable 1 4 Keywords 2 5 Statement 2 6 Expression 2 7 Comment 3 8 Module 3 9 Defining Functions 4 10 Conditional 5 11 Recursion 6 12 Incremental Development 7 13 Recap 8
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CSC326 Python Imperative Core (Lec 2) 1 / 8 1 Agenda • Python imperative core value, type, variable expression, statement module • Incremental development w/t Python 2 Invoking Python • Interactive mode >python Python 2.6.1 (r261, Mar 18 2009, 15:53:57) [GCC 3.2.2] on sunos5 Type "help", "copyright", "credits" or "license" for more information. >>> • Script mode >python foo.py 3 Value, Type, Variable • Value: Basic unit of data program manipulates • Type: A category of values (or a set of values) A type itself is also a value! • Variable: name that refers to a value >>> print ’Hello, World!’ ’Hello, World’ >>>print 4 4 >>> type(4) <type ’int’> >>> type(’4’) <type ’str’> >>> type(’3.2’) <type ’float’> >>> message = ’hi’ >>> n = 17 >>> pi = 3.14 >>> print n 17 >>> print pi 3.14 >>> type(pi) <type ’float’>
Background image of page 4
CSC326 Python Imperative Core (Lec 2) 2 / 8 Note String could be single quoted and double quoted To print "hey" In C printf ("\"hey\" ); print ’"hey"’ • No ; after a statement! • Hex/Oct number representation the same as C >>>zipcode = 02492 SyntaxError: invalid token 4 Keywords • 31 keywords 5 Statement • print statement (obsolete for 3.0) • assignment • more to come 6 Expression • functions (same as C) type(.) was a function function application function composition a( b(v1) ) • operators special symbols representing builtin functions
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/20/2012 for the course CSC 326 taught by Professor Jzhu during the Fall '11 term at University of Toronto.

Page1 / 11

CSC326 Lecture 2 - CSC326 Python Imperative Core (Lec 2)...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online