230 likes | 387 Views
V2012.13. Agenda. Old Business Delete Files New Business Week 18 Topics: Intro to HTML/CSS: Questions? Summer Work Letter to Hyland Upcoming Schedule Group E xecutive Committee Introduction to Programming … Python. HTML/CSS Class. QUESTIONS?. Tech Club Executive Committee.
E N D
Agenda • Old Business • Delete Files • New Business • Week 18 Topics: • Intro to HTML/CSS: Questions? • Summer Work • Letter to Hyland • Upcoming Schedule • Group Executive Committee • Introduction to Programming … Python
HTML/CSS Class QUESTIONS?
Tech Club Executive Committee • Next Year: • Election of Officers • President • Vice President • Secretary • Treasurer • Send me an email with interest
Upcoming Schedule • Today: Intro to Python • May 7th: Intro to Java • May 14th: Intro to C# (Guest Speaker) • May 21st: Embedded Programming
Intro to Programming … Reset! • Language Targets • Python, Java, C# • Our Approach: • Install Tools (if needed) • Start with basic examples (for each language) • Walk step-by-step through each example • Explain each line of code • Explain concepts • Define Terms • Challenges (for each language)
Intro to Python • History • Brief Overview • Installation/Tools • Getting Started • Examples • Resources
… NAMED FOR THESE GUYS! MONTY PYTHON’S FLYING CIRCUS
Python Overview • Over 20 years old • General-purpose, high-level language • Used in math, science, web development, etc. • Emphasizes code readability and simplicity • Dynamic typing • Runs on multiple platforms
“Batteries Included Language” • Python includes a “Standard Library” • A collection of modules to make some set of tasks simpler • Very extensive, offering a wide range of facilities
Python Overview - Strings str = 'Hello World!' print str# Prints complete string print str[0]# Prints first character of the string print str[2:5]# Prints characters starting from 3rd to 6th print str[2:] # Prints string starting from 3rd character print str* 2# Prints string two times print str+ "TEST" # Prints concatenated string
Python Overview - Lists list = [ 'abcd', 786 , 2.23, 'john', 70.2 ] tinylist= [123, 'john'] print list # Prints complete list print list[0]# Prints first element of the list print list[1:3]# Prints elements starting from 2nd to 4th print list[2:]# Prints elements starting from 3rd element print tinylist* 2# Prints list two times print list + tinylist# Prints concatenated lists
Python Overview - Dictionaries • Dictionaries work like associative arrays or hashes and consist of key-value pairs dict= {'name': 'john','code':6734, 'dept': 'sales'} print dict['one'] # Prints value for 'one' key print dict[2] # Prints value for 2 key print tinydict# Prints complete dictionary print tinydict.keys() # Prints all the keys print tinydict.values() # Prints all the values
Python Overview - Functions • Defining a function only gives it a name, specifies the parameters that are to be included in the function, and structures the blocks of code. • Once the basic structure of a function is finalized, you can execute it by calling it from another function or directly from the Python prompt. deffunctionName (parameters):
Python Overview - Functions # Function definition is here defprintme( str ): "This prints a passed string into this function" print str; return; # Now you can call printme function printme("I'm first call to user defined function!"); printme("Again second call to the same function"); function parameter
Python Overview - Modules • A module allows you to logically organize your Python code. Grouping related code into a module makes the code easier to understand and use. • Simply, a module is a file consisting of Python code. A module can define functions, classes, and variables. A module can also include runnable code.
Python Overview - Modules • You can use any Python source file as a module by executing an import statement in some other Python source file. import has the following syntax: import modulename
Getting Started with Python • Download Python • http://www.python.org/getit/ • Already installed with most Linux distributions
Running a Python Program • Create a file with a .pyextension • Add some code • At a terminal prompt, type: python yourfile.py
Resources • Official Python Website • http://www.python.org/ • Python 3 Documentation • http://docs.python.org/3/library/index.html • Learning • CodeAcademy • http://www.codecademy.com/tracks/python • LearningPython.org • http://www.learnpython.org/ • After Hours Programming Python • http://www.afterhoursprogramming.com/tutorial/Python/Overview
Python Tutorial • Good Python Tutorial: • Appears to be geared towards Python 2.7 • http://www.tutorialspoint.com/python/