1 / 19

Python – Part 1

Python – Part 1. Python Programming Language. What is Python? . High-level language Interpreted – easy to test and use interactively Object-oriented Open-source software. What is Python?. Small, simple language Extensible – set of modules as tools to build on the language

nascha
Download Presentation

Python – Part 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Python – Part 1 Python Programming Language

  2. What is Python? • High-level language • Interpreted – easy to test and use interactively • Object-oriented • Open-source software Prepared by Department of Preparatory year

  3. What is Python? • Small, simple language • Extensible – set of modules as tools to build on the language • Familiar – features from other languages (Java, C, Perl) Prepared by Department of Preparatory year

  4. Benefits • Consistency – maintained by a large organization of people • Scalability – Python projects scale to very large projects • Flexibility – use of libraries and programs written in other languages Prepared by Department of Preparatory year

  5. Benefits • Interactive interpreter • Cross-platform • Easy to implement Prepared by Department of Preparatory year

  6. Resources • Python: http://www.python.org • Installing Python: http://www.python.org/download • Python Documentation: http://docs.python.org Prepared by Department of Preparatory year

  7. Resources • Python.org's list of editors and IDEs • http://wiki.python.org/moin/PythonEditors • http://wiki.python.org/moin/IntegratedDevelopmentEnvironments • Think Python • http://www.greenteapress.com/thinkpython/thinkpython.html Prepared by Department of Preparatory year

  8. Python Programs • Executed by an interpreter • Two ways to use interpreter • Interactive mode • Script mode Prepared by Department of Preparatory year

  9. Interactive Mode • >>> 1 + 1 • 2 • >>> is the prompt the interpreter uses to indicate that it is ready. • If you type 1 + 1, the interpreter replies 2. Prepared by Department of Preparatory year

  10. Script Mode • Store code in a file • Use the interpreter to execute the contents of the file (called script, .py extention) Prepared by Department of Preparatory year

  11. Programs • A program is a sequence of instructions that specifies how to perform a computation. • input: • Get data from the keyboard, a file, or some other device. • output: • Display data on the screen or send data to a file or other device. Prepared by Department of Preparatory year

  12. Programs (cont…) • math: • Perform basic mathematical operations like addition and multiplication. • conditional execution: • Check for certain conditions and execute the appropriate sequence of statements. • repetition: • Perform some action repeatedly, usually with some variation. Prepared by Department of Preparatory year

  13. Debugging • Programming errors are called bugs • Debugging - the process of tracking them down. • Three kinds of errors: • syntax errors • runtime errors • semantic errors Prepared by Department of Preparatory year

  14. Syntax errors • Occur if syntax is not correct • Syntax refers to the structure of a program and the rules about that structure. • (1 + 2) is legal • 8) is a syntax error Prepared by Department of Preparatory year

  15. Runtime errors • Error does not appear until after the program has started running • Also called exceptions • Rare in simple programs Prepared by Department of Preparatory year

  16. Semantic errors • Program runs successfully (no error messages generated) • Will not do the right thing • The meaning of the program (its semantics) is wrong. • Tricky to indentify Prepared by Department of Preparatory year

  17. The first program • Hello World program • print (‘Hello, World!’) • Print statement • Display on the screen: • Hello World Prepared by Department of Preparatory year

  18. Exercise • Start the Python interpreter and use it as a calculator. • The symbol for multiplication is *. • If you run a 10 kilometer race in 43 minutes 30 seconds, what is your average time per mile? What is your average speed in miles per hour? (Hint: there are 1.61 kilometers in a mile). Prepared by Department of Preparatory year

  19. Part 1 References http://www.greenteapress.com/thinkpython/thinkpython.html

More Related