August 29, 2005ICP: Chapter 1: Introduction to Python Programming 1 Introduction to Computer Programming Chapter 1: Introduction to Python Programming.

Download August 29, 2005ICP: Chapter 1: Introduction to Python Programming 1 Introduction to Computer Programming Chapter 1: Introduction to Python Programming.

Post on 31-Dec-2015

221 views

Category:

Documents

8 download

TRANSCRIPT

  • Introduction to Computer ProgrammingChapter 1: Introduction to Python ProgrammingMichael SchergerDepartment of Computer ScienceKent State University

    ICP: Chapter 1: Introduction to Python Programming

  • The Game Over Program

    ICP: Chapter 1: Introduction to Python Programming

  • History of PythonCreated in 1989 by Guido van RossumCreated as a scripting language for administrative tasksBased on All Basic Code (ABC) and Modula-3Added extensibilityNamed after comic troupe Monty PythonReleased publicly in 1991Growing community of Python developersEvolved into well-supported programming language

    ICP: Chapter 1: Introduction to Python Programming

  • History of PythonModulesReusable pieces of softwareCan be written by any Python developerExtend Pythons capabilitiesPython Web site at www.python.orgPrimary distribution center for Python source code, modules and documentation

    ICP: Chapter 1: Introduction to Python Programming

  • History of PythonPythonDesigned to be portable and extensibleOriginally implemented on UNIXPrograms often can be ported from one operating system to another without any changeSyntax and design promote good programming practices and surprisingly rapid development timesSimple enough to be used by beginning programmersPowerful enough to attract professionals

    ICP: Chapter 1: Introduction to Python Programming

  • Setting Up Python on WindowsGo to http://www.python.org and get the latest distribution (2.4.1)Online tutorialsPython related websitesUse the distribution on the CD ROM supplied with the textbookExamples from the bookUse all the defaults when installing

    ICP: Chapter 1: Introduction to Python Programming

  • Python IDLE

    ICP: Chapter 1: Introduction to Python Programming

  • Your First Python ProgramAt the prompt (>>>) type:

    print Game OverPress [Enter]

    Very straightforwardYou could have guessed what this does without knowing Python!

    ICP: Chapter 1: Introduction to Python Programming

  • Your First Python ProgramPython is case-sensitiveprint Game OverPrint Game OverPRINT Game Over

    ICP: Chapter 1: Introduction to Python Programming

  • Your First Python ProgramIn Python, this computer instruction is called a statementCommand (like a verb) (print)Expression (like a value) (Game Over)

    More specifically, Game Over is called a string expressionA series of characters between

    ICP: Chapter 1: Introduction to Python Programming

  • Syntax ErrorsWhen the computer does not recognize the statement to be executed, a syntax error is generatedAnalogous to a misspelled word in a programming languageBug

    >>> primt Game OverSyntaxError: invalid syntax

    ICP: Chapter 1: Introduction to Python Programming

  • Programming in Script ModeInteractive mode gives you immediate feedbackNot designed to create programs to save and run laterScript ModeWrite, edit, save, and run (later)Word processor for your codeSave your file using the .py extension

    ICP: Chapter 1: Introduction to Python Programming

  • Program DocumentationComment lines provide documentation about your programAnything after the # symbol is a commentIgnored by the computer

    # Ima P Programmer# First Python Program# September 1, 2005

    ICP: Chapter 1: Introduction to Python Programming

  • Text ExamplesGame Over Example

    ICP: Chapter 1: Introduction to Python Programming

Recommended

View more >