12/19 I cant understand


Alright, so 12/19 wants us to understand the code given. I didn’t understand anything, especially arg and arg*. Can someone also explain to me why the console wrote the following?:


The code is:

  print max(args)
  return max(args)
def smallest_number(*args):
  print min(args)
  return min(args)

def distance_from_zero(arg):
  print abs(arg)
  return abs(arg)

biggest_number(-10, -5, 5, 10)
smallest_number(-10, -5, 5, 10)



*args allows for a tuple (immutable list), this is very useful if you have an unknown number of arguments, we can see this by simple printing args and its type:

def biggest_number(*args):
     print args
     print type(args)

biggest_number(-10, -5, 5, 10)

for more info see:

so the output is caused by getting the max value from args in first function (biggest_number), the minimum value from the second function args, and the absolute (abs) value for the third function


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.