python programming

Download Python programming

Post on 13-Aug-2015

85 views

Category:

Technology

3 download

Embed Size (px)

TRANSCRIPT

  1. 1. Python Programming Ameer Fazal
  2. 2. Designed by Guido van Rossum First appeared in 1991 As a successor to the ABC Language
  3. 3. Python Official Website www.python.org Distributed under FLOSS (Free/Libr and Open Source Software) Sharing is Caring
  4. 4. Named after the BBC Comedy Troupe Monty Python and the Flying Circus
  5. 5. What is Python General Purpose High Level Interpreted Open Source Programming Language
  6. 6. Why Python Ease of Use and Powerful Community Driven Currently its in the top eight programming languages in the world according to TIOBE Index Two times winner of Programming Language of the Year(2007 and 2010) by TIOBE Index
  7. 7. Some Organizations Using Python Google Yahoo Walt Disney Feature Animation NASA Red Hat Nokia IBM CERN Website of CIA Quora Instagram
  8. 8. A ranking of the highest-paying programming languages by average salaries. (ViaQuartz)
  9. 9. Python 2 and Python 3 Python 2.x is legacy Python 3.x is the present and future of the language In this tutorial we are using both Python 3 and Python 2
  10. 10. Installation on Windows Go to https://www.python.org/downloads/ Click Download Python 3.4.1 (or later) for Windows (a .msi file)
  11. 11. Python Interpreter
  12. 12. Hello World! Program print(Hello World!)
  13. 13. Interactive Programming in the Interpreter
  14. 14. Python is Interpreted Python does not need compilation to binary Python converts the source code into an intermediate form called bytecodes Then translates this into the native language of your computer and then runs it
  15. 15. Python is Object Oriented Python supports procedure-oriented programming as well as object-oriented programming Python has a very powerful but simplistic way of doing OOP, especially when compared to big languages like C++ or Java.
  16. 16. Python is Simple Python is a simple and minimalistic language. Reading a good Python program feels almost like reading English, although very strict English!
  17. 17. Python is Easy to Learn As you will see, Python is extremely easy to get started with. Python has an extraordinarily simple syntax, as already mentioned
  18. 18. The Zen of Python The core philosophy of the language is summarized by the document "PEP 20 (The Zen of Python)", which includes aphorisms such as: Beautiful is better than ugly Explicit is better than implicit Simple is better than complex Complex is better than complicated Readability counts
  19. 19. The Zen of Python
  20. 20. Getting Help You can use the built-in help functionality E.g. help(print) Press q to exit the help.
  21. 21. Saving Python Programs Type the program in Integrated Development Environment or a Text Editor Program and save it as .py file extension
  22. 22. Comments Comments are ignored by Python Interpreter # Symbol for Single Line Comments Triple Quotes for Multi Line Comments ( or ) Code tells you how, comments should tell you why.
  23. 23. Comments Use as many useful comments as you can in your program to: explain assumptions explain important decisions explain important details explain problems youre trying to solve explain problems youre trying to overcome in your program, etc.
  24. 24. Literal Constants It is called a literal because it is literal you use its value literally It is a constant because its value cannot be changed E.g. Numbers- 5, 1.23 Strings- hello
  25. 25. Numbers Numbers are mainly of two types - integers and floats Integers- Whole Numbers- e.g. 2, 3, 10, 997 Floating Point Numbers- e.g. 3.25, 4.0 Note for Experienced Programmers: There is no separate long type. The int type can be an integer of any size.
  26. 26. Strings A string is a sequence of characters Strings are basically just a bunch of words Single Quote - e.g. Quote me on this. Double Quotes - e.g. "Whats your name? Triple Quotes Can use for strings that span on multiple lines e.g.'''This is a multi-line string. This is the first line. This is the second line. "What's your name?," I asked. He said "Bond, James Bond. '''
  27. 27. Strings Are Immutable This means that once you have created a string, you cannot change it You can make a new string out of an existing string
  28. 28. Raw String If you need to specify some strings where no special processing such as escape sequences are handled then what you need is to specify a raw string by prefixing r or R to the string Raw String and Normal String
  29. 29. Escape Sequences Escape Sequences use an escape character to change the meaning of the characters which follow it, meaning that the characters can be interpreted as a command rather than as data E.g. t n
  30. 30. Variables Variables are always references to objects, and are never typed They are Case Sensitive Variables in Python are automatically declared by assignment
  31. 31. Identifier Naming Identifiers are names given to identify Something The first character of the identifier must be a letter of the alphabet or an underscore (_) The rest of the identifier name can consist of letters , underscores (_) or digits (0-9) Identifier names are case-sensitive
  32. 32. How to write Python programs 1. Open your editor of choice 2. Type the program code given in the example 3. Save it as a file with the filename mentioned 4. Run the interpreter with the command python3 program.py (or python program.py on Windows) to run the program
  33. 33. Thanks Wikipedia Python Official Website Swaroop C H