Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at


123 :: Python

<< First, < Previous, , Latest >>

Hosted by Cottonballs on 2006-07-05 is flagged as Explicit and is released under a CC-BY-NC-SA license.
.

Listen in mp3 format. Play now:

Duration: 00:19:40

Listen in mp3 format.

general.

Learning with python though examples

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\\>python
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32
Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.
>>> print \"HELLO\" # Number signs will comment
HELLO

>>> name = \"Cotton\"
# the variable \"name\" has been defined to the string \"Cotton\"
>>> def hello():
... print \"Hello there, %s\"%name
...
# hello() is now a function
>>> hello()
Hello there, Cotton

# alittle more complicated

>>> def hello2(user): # we now made \"user\" and argument.
... print \"Hello there, %s\"% user
...
>>> hello2()
# U cannot call hello2(user) without an argument.
Traceback (most recent call last):
File \"\", line 1, in ?
TypeError: hello2() takes exactly 1 argument (0 given)

>>> hello2(\"infonomicon\")
Hello there, infonomicon

>>> nicks = [\"John\",\"Billy\", \"Python\", \"Cotton\", \"twat\"] #nicks has been defined as a list
>>> nicks
[\'John\', \'Billy\', \'Python\', \'Cotton\', \'twat\']
>>> for i in nicks:
... hello2(i)
...
Hello there, John
Hello there, Billy
Hello there, Python
Hello there, Cotton
Hello there, twat

# For more help, visit http://www.ibiblio.org/obp/thinkCSpy/ That site has helped me tremendously!
# Email me cbmailone[at]gmail[dot]com
Great Python Tutorials:

http://www.ibiblio.org/obp/thinkCSpy/
http://www.ibiblio.org/g2swap/byteofpython/read/index.html
http://diveintopython.org/toc/index.html