a python tutorial

11
A Python Tutorial Computer Science and Engineering Association NIT Calicut Code Maestros

Upload: kartik-singhal

Post on 14-Jan-2015

874 views

Category:

Technology


1 download

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

A Python Tutorial

Computer Science and Engineering Association

            NIT Calicut

                          Code Maestros

Page 2: A Python Tutorial

●Why Python?● Interpreter Fun● Live Demo ●Scripts● Examples and QA ● Python in...● References● License and Sharing Info

Contents

Page 3: A Python Tutorial

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

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

Live demo

Page 6: A Python Tutorial

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

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

Examples and QA

Page 9: A Python Tutorial

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

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

License and Sharing Info

This work by CSEA, NIT Calicut is licensed under a Creative Commons Attribution-NonCommercial 2.5 India License.