Robotics & Artificial Intelligence
Write a function that returns the greater of two numbers passed as arguments.
Python Functions
2 Likes
Answer
def greater(a, b):
if a > b:
return a
else:
return b
x = int(input("Enter first number: "))
y = int(input("Enter second number: "))
result = greater(x, y)
print("Greater number is:", result)Output
Enter first number: 80
Enter second number: 82
Greater number is: 82
Answered By
3 Likes
Related Questions
Write a Python program to demonstrate the concept of default arguments in a function.
Is the return statement mandatory for every function?
Write a function called ice_water that takes a number as input. Perform the following operations:
- If the number is divisible by 3, then it should return "ice".
- If it is divisible by 5, then it should return "water".
- If it is divisible by both 3 and 5, then it should return "icewater".
- Otherwise, it should return the same number.
Write a function for checking the speed of drivers. This function should have one parameter: speed.
- If speed is less than 70, it should print "OK".
- Otherwise, for every 5 km above the speed limit (70), it should give the driver one demerit point. Calculate and print the total number of demerit points at the end. For example, if the speed is 80, it should print: "Demerit Points: 2".
- If the driver gets more than 12 demerit points, the function should print: "License suspended".