a python tutorial
DESCRIPTION
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/TRANSCRIPT
![Page 1: A Python Tutorial](https://reader035.vdocument.in/reader035/viewer/2022073101/54b613944a7959e7658b4653/html5/thumbnails/1.jpg)
A Python Tutorial
Computer Science and Engineering Association
NIT Calicut
Code Maestros
![Page 2: A Python Tutorial](https://reader035.vdocument.in/reader035/viewer/2022073101/54b613944a7959e7658b4653/html5/thumbnails/2.jpg)
●Why Python?● Interpreter Fun● Live Demo ●Scripts● Examples and QA ● Python in...● References● License and Sharing Info
Contents
![Page 3: A Python Tutorial](https://reader035.vdocument.in/reader035/viewer/2022073101/54b613944a7959e7658b4653/html5/thumbnails/3.jpg)
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
![Page 4: A Python Tutorial](https://reader035.vdocument.in/reader035/viewer/2022073101/54b613944a7959e7658b4653/html5/thumbnails/4.jpg)
Interpreter Fun
● Python interpreter - good for little experiments● read-eval-print loop●No need to declare variables● Variables don't 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.>>>
![Page 5: A Python Tutorial](https://reader035.vdocument.in/reader035/viewer/2022073101/54b613944a7959e7658b4653/html5/thumbnails/5.jpg)
Live demo
![Page 6: A Python Tutorial](https://reader035.vdocument.in/reader035/viewer/2022073101/54b613944a7959e7658b4653/html5/thumbnails/6.jpg)
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()
![Page 7: A Python Tutorial](https://reader035.vdocument.in/reader035/viewer/2022073101/54b613944a7959e7658b4653/html5/thumbnails/7.jpg)
def main(): args = sys.argv[1:] for filename in args: if filename == 'voldemort'or filename == 'vader': print 'this file is very worrying' cat(filemane, 123, bad_variable) else: cat(filename) print 'all done' if __name__ == '__main__': main()
Continues...
![Page 8: A Python Tutorial](https://reader035.vdocument.in/reader035/viewer/2022073101/54b613944a7959e7658b4653/html5/thumbnails/8.jpg)
Examples and QA
![Page 9: A Python Tutorial](https://reader035.vdocument.in/reader035/viewer/2022073101/54b613944a7959e7658b4653/html5/thumbnails/9.jpg)
Python in...
●Web○Django, ZOPE, WebPy, TurboGears
●Scientific Computing○NumPy, SAGE
●GUI Development○ PyGtk, PyQt
●Game Dev○ PyGame
●Network Programming○Twisted
![Page 10: A Python Tutorial](https://reader035.vdocument.in/reader035/viewer/2022073101/54b613944a7959e7658b4653/html5/thumbnails/10.jpg)
References
● Python in One Easy Lesson - http://www-cs-faculty.stanford.edu/~nick/python-in-one-easy-lesson/
●Google's Python Class - http://code.google.com/edu/languages/google-python-class/index.html
![Page 11: A Python Tutorial](https://reader035.vdocument.in/reader035/viewer/2022073101/54b613944a7959e7658b4653/html5/thumbnails/11.jpg)
License and Sharing Info
This work by CSEA, NIT Calicut is licensed under a Creative Commons Attribution-NonCommercial 2.5 India License.