Presentation is loading. Please wait.

Presentation is loading. Please wait.

Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source.

Similar presentations


Presentation on theme: "Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source."— Presentation transcript:

1 Python – Part 1 Python Programming Language 1

2 What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source software 2 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) 3 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 4 Prepared by Department of Preparatory year

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

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

7 Resources Python.org's list of editors and IDEseditorsIDEs – http://wiki.python.org/moin/PythonEditors http://wiki.python.org/moin/PythonEditors – http://wiki.python.org/moin/IntegratedDevelopm entEnvironments http://wiki.python.org/moin/IntegratedDevelopm entEnvironments Think Python – http://www.greenteapress.com/thinkpython/thin kpython.html http://www.greenteapress.com/thinkpython/thin kpython.html 7 Prepared by Department of Preparatory year

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

9 Installing Python Python 3 is used in this course http://www.youtube.com/watch?v=4Mf0h3H phEA http://www.youtube.com/watch?v=4Mf0h3H phEA http://www.ehow.com/how_2116627_install- python-windows.html http://www.ehow.com/how_2116627_install- python-windows.html Prepared by Department of Preparatory year 9

10 InteractiveMode >>> 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

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

12 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. 12 Prepared by Department of Preparatory year

13 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. 13 Prepared by Department of Preparatory year

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

15 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 15 Prepared by Department of Preparatory year

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

17 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 identify 17 Prepared by Department of Preparatory year

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

19 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). 19 Prepared by Department of Preparatory year

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


Download ppt "Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source."

Similar presentations


Ads by Google