Hello world

742 views
691 views

Published on

Simple examples of python code implementing "hello world". Given at the first Memphis Python User group meeting (2011-11-21).

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
742
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Hello world

    1. 1. Welcome to MEMpy Brad Montgomery http://mempy.org
    2. 2. print(hello world)
    3. 3. Python• multi-platform• multi-paradigm• dynamically-typed• big standard lib (tons of 3rd party libs)• open source• by Guido van Rossum (BDFL)
    4. 4. the interpreter• An interactive Python shell• In a *nix environment, open a terminal and type: python• In Windows, run IDLE
    5. 5. IDLE
    6. 6. the interpreter>>> print(hello world)hello world>>> 31 + 1142>>>
    7. 7. functions# save this in a file named "greeting.py"def hello(input_name=world): greeting = "Hello {name}".format( name=input_name) return greeting>>> from greeting import hello>>>>>> hello()Hello world>>>>>> hello("Universe")Hello Universe
    8. 8. modules/packages• namespaces!• module: a file with python code: greeting.py• package: a directory of python modules
    9. 9. modules/packages>>> from greetingapp import greeting>>>>>> greeting.hello()Hello world>>>>>> greeting.hello("Universe")Hello Universe
    10. 10. classesclass Greeter(object): names = [World ] def hello(self, names=None): if names: self.names = names for name in self.names: s = Hello {n}.format(n=name) print(s)
    11. 11. classes>>> from greeting import Greeter>>> g = Greeter()>>> g.hello()Hello World>>> g.hello([Bill, Betty])Hello BillHello Betty>>>
    12. 12. who’s using python?• Google • EDU’s• YouTube • CERN• Nasa • ESRI• Astra-Zeneca • CCP Games• Lucasfilm • Silicon Valley Startups• Reddit • Hobbyists
    13. 13. learn more• http://learnpythonthehardway.org/• http://openbookproject.net/thinkCSpy/• http://docs.python.org/tutorial/

    ×