1 / 41

Introduction to Python

Introduction to Python. `09 Summer SP ARCS Seminar. SPARCS `08 서우석 ( pipoket ). Python?. Father Guido Van Rossum Birth-year 1989 Born at Amsterdam. Python?. Platform independent Interpreter Language Script Language Supports OOP Object Oriented Programming. Why Python.

drago
Download Presentation

Introduction to Python

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Python `09 Summer SPARCS Seminar SPARCS `08 서우석(pipoket)

  2. Python? Father Guido Van Rossum Birth-year 1989 Born at Amsterdam

  3. Python? Platform independent Interpreter Language Script Language Supports OOP Object Oriented Programming

  4. Why Python Easy Syntax Easy Grammar Easy Data Structure Many Packages Very Readable Very Flexible Usually Short Code Easy to Manage Code Easy to Work Together

  5. Python! SPARCS Works Together with…

  6. Get Python! http://www.python.org DOWNLOAD Recommended Version 2.6.X <= On Windows

  7. Get Python! On Debian Linux ~# apt-get install python • ~$ sudo apt-get install python

  8. Run Python! ~$ python

  9. Run Python! ~# apt-get install ipython ~# ipython

  10. Python Syntax Use python as simple calculator >>> 1 + 2 >>> 6 * 8 >>> 6.0 * 8 >>> 2 ^ 10 >>> 2 ** 10 >>> _ / 2 >>> __ / 4 >>> _

  11. Python Syntax Print the “Hello world!” >>> print “Hello World!” >>> print(“Hello World!”)

  12. Python Syntax Multiline Text Single Quote INDENTATION!!

  13. Python Syntax Indentation is also Syntax!!!

  14. Python Syntax You MUST keep the same indentation!

  15. Python Variables But you don’t have to care!

  16. Python Variables Dynamic Typing

  17. Do It Yourself #1 Your program should do the following 1. Calculate the 224 2. Save the result to “result” 3. Print the “result”

  18. Python Controls if for while try, except

  19. if “a is three”

  20. for

  21. while

  22. try, except

  23. Do It Yourself #2 Your program should do the following 1. Print out the even numbers between 1 to 1000, without line breaks 2. Print out the 1000 / n When n is between -100 to 100

  24. Number 7 0 7.0 0.75 5+5j

  25. String

  26. String

  27. Do It Yourself #3 Your program should do the following 1. Let given=“we are so friend!” 2. Using slicing, concatenating, indexing, and methods, make following result - “we are friend!” - “are WE so friend” - “so friend we are”

  28. List, Tuple

  29. List, Tuple

  30. Do It Yourself #4 Your program should do the following 1. Let given=range(100) 2. Using the given, get the following - Even number between 0~99 - Odd number between 0~99 - Multiplier of 3 between 0~50, 70~99 - List starts from 99 and ends at 1

  31. Dictionary

  32. Dictionary

  33. Dictionary

  34. Simple input

  35. Do It Yourself #5 Your program should do the following 1. Get the input Name and Age 2. Save the Name and Age to dictionary 3. If input is empty Change the input mode to search4. On search mode Print the age of given name

  36. File Operation

  37. Summary Now you know… How to Install and Run Python How to Use Python as Calculator Basic Python Syntax (indentation, quote, multiline text…) Python Data Structure (string, number, list, dictionary, tuple…) Basic Input, Output to the terminal (input_raw, input, print) Basic File Operation (open, write, readline, close …)

  38. Summary You have just learned 50% of python!

  39. Next Function Class with OOP (Inheritance, Overloading, Overriding …) Package Advanced Python Topics Simple Format String List Generating Generator (yield) Lambda Function (lambda)

  40. Homework • You should review all the materials we have discussed • You can get the codes used in this ppthttp://pipoket.kaist.ac.kr/sp_seminar/week01.tar.gz • Following command will expand the file on Linux ~# tar –zxvf week01.tar.gz

  41. Homework Your program should do the following 1. Open the given file diy6.db 2. File is like this“20080421[TAB]Woosuk Suh[TAB]Computer Science” “20080719TAB]Chanhee Lee[TAB]Undecided” 3. Read the file and save the data as you wish 4. Get the Student ID as input and print out the information of student

More Related