-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex18.py
More file actions
26 lines (21 loc) · 747 Bytes
/
ex18.py
File metadata and controls
26 lines (21 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Exercise 18: Names, Variables, Code, Functions
# http://learnpythonthehardway.org/book/ex18.html
# function definition with argument unpacking like with argv
def print_two(*args):
"""Takes two arguments, unpacks and prints them."""
arg1, arg2 = args
print "arg1: %r, arg2: %r" % (arg1, arg2)
def print_two_again(arg1, arg2):
"""Takes two arguments and prints them without unpacking"""
print "arg1: %r, arg2: %r" % (arg1, arg2)
def print_one(arg1):
"""Takes just one argument."""
print "arg1: %r" % arg1
def print_none():
"""Takes no arguments."""
print "I got nothin'."
# function calls with arguments (in number and order as defined above)
print_two("Zed", "Shaw")
print_two_again("Zed", "Shaw")
print_one("First!")
print_none()