A Python Tutorial

1,034
-1

Published on

Presentation used for tutorial session on Python for finalists of CSEA Code Maestros on Feb 11, 2012. More resources at http://athena.nitc.ac.in/~k4rtik/python/

Published in: Technology, Education
2 Comments
2 Likes
Statistics
Notes
No Downloads
Views
Total Views
1,034
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
12
Comments
2
Likes
2
Embeds 0
No embeds

No notes for slide

A Python Tutorial

  1. 1. A Python Tutorial Computer Science and Engineering Association             NIT Calicut                          Code Maestros
  2. 2. Contents● Why Python?● Interpreter Fun● Live Demo● Scripts● Examples and QA● Python in...● References● License and Sharing Info
  3. 3. Why Python?● Popular● Open Source● Cross Platform● Easy to learn● Forces the programmer to write readable code● General purpose - used almost everywhere from games to robotics
  4. 4. Interpreter Fun ● Python interpreter - good for little experiments ● read-eval-print loop ● No need to declare variables ● Variables dont have types, but values do k4rtik@PlatiniumLight ~ $ pythonPython 2.7.2+ (default, Oct 4 2011, 20:06:09)[GCC 4.6.1] on linux2Type "help", "copyright", "credits" or"license" for more information.>>>
  5. 5. Live demo
  6. 6. Scripts (like bash!)#!/usr/bin/pythonimport sysa = 123def cat(filename): """Given filename, print its text contents.""" print filename, ======= f = open(filename, r) for line in f: print line, f.close()
  7. 7. Continues...def main(): args = sys.argv[1:] for filename in args: if filename == voldemortor filename == vader: print this file is very worrying cat(filemane, 123, bad_variable) else: cat(filename) print all doneif __name__ == __main__: main()
  8. 8. Examples and QA
  9. 9. Python in... ● Web ○ Django, ZOPE, WebPy, TurboGears ● Scientific Computing ○ NumPy, SAGE ● GUI Development ○ PyGtk, PyQt ● Game Dev ○ PyGame ● Network Programming ○ Twisted
  10. 10. References● Python in One Easy Lesson - http://www-cs-faculty. stanford.edu/~nick/python-in-one-easy-lesson/● Googles Python Class - http://code.google. com/edu/languages/google-python-class/index.html
  11. 11. License and Sharing InfoThis work by CSEA, NIT Calicut is licensed under a CreativeCommons Attribution-NonCommercial 2.5 India License.

×