lec2 - CSC326 Python Imperative Core(Lec 2 CSC326 Python...

Info icon This 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)
Image of page 1

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

View Full Document Right Arrow Icon
CSC326 Python Imperative Core (Lec 2) ii REVISION HISTORY NUMBER DATE DESCRIPTION NAME 1.0 2011-09 JZ
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
Image of page 3

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

View Full Document Right 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’>
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 apply on operands (unary or binary)
Image of page 5

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern