Use the max function to calculate max3(x, y, z) if x = 2, y = 6, z = 5.
Show your work!
# Python Program to find Max number from given number
# Best way to run this code in pycharm editor
def max3(x, y, z): #Define Function with x,y and z variable
if (x > y) and (x > z): # Compare x with y and z to know x is grater than y and z
largest = x
elif ( y > x) and (y > z): # Compare y with x and z to know y is grater than x and z
largest = y
else: # if above condition is fails then z is maximum
largest = z
return largest
#Driven Code
x = 2
y = 6
z = 5
print ( max3(x, y, z) )
Output of this code :
6
Get Answers For Free
Most questions answered within 1 hours.