In [1]:
from __future__ import print_function
In [2]:
def show_names(first_name, last_name):
print(
'Your first name is %r. Your last name is %r.' %
(first_name, last_name))
In [3]:
show_names('Even', 'Wager')
show_names(1234, 'wager')
# wager = 3.1415926
show_names(1234, wager)
In [4]:
def goo(blah):
print('do this')
print('do that')
In [5]:
goo('lasdjkf')
In [6]:
goo()
In [7]:
goo(1, 2)
In [8]:
def print_two(*args):
# This is a terrible terrible example of *args.
print(type(args), repr(args))
arg1, arg2 = args
print("arg1: %r, arg2: %r" % (arg1, arg2))
In [9]:
print_two(1234, 'ehllo')
In [10]:
type([])
Out[10]:
In [11]:
type(())
Out[11]:
In [12]:
def foo(*args):
print(type(args), args)
In [13]:
foo(True, 'hello', 'world', 1234, 3.1415926, range(3))
In [14]:
for i in [0, 5, 9]:
print('hello')
print(i)
print(i*i)
print(i*i*i)
print()
In [15]:
def foo(*args):
print(type(args), args)
for arg in args:
print('an argument is', arg)
In [16]:
foo(True, 'hello', 'world', 1234, 3.1415926, range(3))
In [17]:
def foo(*args):
print(type(args), args)
for i, arg in enumerate(args):
print('Argument #', i, 'is', arg)
In [18]:
foo(True, 'hello', 'world', 1234, 3.1415926, range(3))
In [19]:
def foo(*args):
print(type(args), args)
for i, arg in enumerate(args):
print('Argument #%s is %r' % (i, arg))
In [20]:
foo(True, 'hello', 'world', 1234, 3.1415926, range(3))