REMEMBER PYTHON

MINTE9
2REMEMBER




FUNCTIONS

p212 ! A function can return only one value, but if the value is a tuple ... the effect is the same as returning multiple values. If you want to compute the quontient and reminders it is better to ... compute both at the same time.
 RunCode
quot = 7//3
rem = 7%3
print(quot, rem)  # 2 1

quot, rem = divmod(7, 3)  # built-in function
print(quot, rem)  # 2 1
... 5 lines
˄˄˄
p213 ! Functions can take a variable number of arguments. A parameter name that begins with * gathers arguments into a tuple.
 RunCode
t = (7, 3)
#divmod(t)  # doesn't work
divmod(*t)  # it works!
... 3 lines
˄˄˄

Questions    
No. 21   Files
CARD
20
32

        A B C D E F
🔔
1/1