TECH PIXEL

Welcome to Python Practice Projects at techtpixel.xyz — your one-stop hub to master Python through real-world, beginner to advanced projects. Learn by building web apps, scripts, automation tools, APIs, and more. Whether you're into data science, Django, Flask, or interview prep, our hands-on tutorials help you level up your skills and build a strong portfolio. Start coding smarter with practical Python challenges today!

PYTHON EXERCISE SOLUTION

 

#SOLO LEARN EXE

*args 

The given code defined a function called my_min(), which takes two arguments and returns the smaller one.

You need to improve the function, so that it can take any number of variables, so that the function call works.

Remember, *args can be accessed inside the function as a tuple.

SOLUTION:

def my_min(x, y, *args):
       return min (args)
       if x < y:
           return x
       else:
           return y
print(my_min( 8, 13, 4, 42, 120, 7))

Post a Comment

0 Comments