Successfully reported this slideshow.

Python 3 Intro Presentation for NEWLUG

1,205 views

Published on

An introduction to programming in Python 3, aimed at people who are new to programming.

Published in: Technology
  • Be the first to comment

Python 3 Intro Presentation for NEWLUG

  1. 1. Python 3 for n00bs <ul>NEWLUG Presentation: June 17th, 2010 Presented by: Ross Larson <li>Software Developer, Cooperative Resources International </li></ul>
  2. 2. So, What is Python, anyways? <ul><li>Named in honor of Monty Python
  3. 3. Created in the late 80's by Guido van Rossum
  4. 4. Designed to be fun to use, as well as flexible. </li></ul>
  5. 5. Python, a Brief version history <ul><li>Conceived in the late 80's, implementation started in December 1989
  6. 6. Version 2.0 – October 16th, 2000 </li><ul><li>Development shifts to a more transparent, community-backed process </li></ul><li>Version 3.0 – December 3rd, 2008 </li><ul><li>Backwards incompatible with previous versions
  7. 7. Some developers still choose to use Python 2.6 </li></ul></ul>
  8. 8. So, why use Python? <ul><li>Lots of Stuff Uses it! </li><ul><li>Django
  9. 9. PyGame
  10. 10. Google App Engine
  11. 11. Quickly
  12. 12. PyQt
  13. 13. PyGtk
  14. 14. Zope
  15. 15. And....more! </li></ul></ul>
  16. 16. OK! Great! I'm in! Now what? <ul><li>To install Python 3 in Ubuntu, search for ”python3” and install it via synaptic.
  17. 17. Development can be done either in a text editor like gedit, vim, or gvim
  18. 18. Integrated Development Environments (IDEs) are available, as well (IDLE, PyDev for Eclipse).
  19. 19. I wrote a PyDev install HOWTO on my blog: </li><ul><li>http://bit.ly/pydev-NEWLUG </li></ul></ul>
  20. 20. Uh, I'm lost! Is there any documentation? <ul><li>Plenty! </li><ul><li>Python website ( http://docs.python.org/py3k/ )
  21. 21. Dive into Python ( http://diveintopython3.org )
  22. 22. Koders Code Search ( http://www.koders.com/ )
  23. 23. YouTube tutorials
  24. 24. Google
  25. 25. IRC channels </li></ul></ul>
  26. 26. The Zen of Python - by Tim Peters <ul><li>Beautiful is better than ugly.
  27. 27. Explicit is better than implicit.
  28. 28. Simple is better than complex.
  29. 29. Complex is better than complicated.
  30. 30. Flat is better than nested.
  31. 31. Sparse is better than dense.
  32. 32. Readability counts. </li></ul>
  33. 33. Zen of Python, Part 2 <ul><li>Special cases aren't special enough to break the rules.
  34. 34. Although practicality beats purity.
  35. 35. Errors should never pass silently.
  36. 36. Unless explicitly silenced.
  37. 37. In the face of ambiguity, refuse the temptation to guess. </li></ul>
  38. 38. Zen of Python, Part 3 <ul><li>There should be one-- and preferably only one --obvious way to do it.
  39. 39. Although that way may not be obvious at first unless you're Dutch.
  40. 40. Now is better than never.
  41. 41. Although never is often better than right now.
  42. 42. If the implementation is hard to explain, it's a bad idea.
  43. 43. If the implementation is easy to explain, it may be a good idea.
  44. 44. Namespaces are one honking great idea -- let's do more of those! </li></ul>
  45. 45. OK, Let's open up Python3 <ul><li>To open the Python 3 Interpreter, type ”python3” at the command line.
  46. 46. woo@beast:~$ python3
  47. 47. Python 3.1.2 (r312:79147, Apr 15 2010, 15:35:48)
  48. 48. [GCC 4.4.3] on linux2
  49. 49. Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
  50. 50. >>> </li></ul>
  51. 51. Now, Let's write a simple program! <ul>>>> print(&quot;Hello NEWLUG!&quot;) Hello NEWLUG! </ul>
  52. 52. OK, I'm still with you. <ul><li>How about variables?
  53. 53. >>> newlug = &quot;San Dimas High School Football Rules!&quot;
  54. 54. >>> print(newlug)
  55. 55. San Dimas High School Football Rules! </li></ul>
  56. 56. OK, fine. But what if I don't want to type everything when I run it? <ul><li>Open a new empty file.
  57. 57. Name it ”helloNEWLUG.py”
  58. 58. Insert:
  59. 59. print(&quot;Hello NEWLUG!&quot;)
  60. 60. Save and Close the file. </li></ul>
  61. 61. OK. Fine. Whatever. <ul><li>From the command line, type: </li><ul><li>python3 helloNEWLUG.py </li></ul></ul>
  62. 62. Wow, now I'm a programmer! <ul>Well, kind of. There is quite a bit more to learn. <li>Everything is an Object!
  63. 63. Data types (String, Boolean, Tuple, Dictionary, etc)
  64. 64. Functions
  65. 65. Arguments
  66. 66. User Input
  67. 67. Exception Handling and Redirection
  68. 68. Loops </li></ul>
  69. 69. Soon, this will make sense:
  70. 70. Watch out for.... <ul><li>Indentation and Spacing </li><ul><li>Never use combinations of tabs and spaces!
  71. 71. ”If you use both tabs and spaces in a Python program, that makes you a bad person” - Brian Blazer </li></ul><li>Different Versions of Python </li><ul><li>The default ”python” is often Python 2.6!
  72. 72. Python scripts can be converted to Python 3 </li></ul><li>The ”loosey-goosey” nature of Python </li><ul><li>Python gives you enough rope to hang yourself. </li></ul></ul>
  73. 73. ...And now for something completely different
  74. 74. Questions?

×