write an algorithm to find the youngest of two brothers Ali and Junaid.
Answers
def yungest(ages):
if len(set(ages.values())) == 1:
return "Same ages!"
sorted_ages = dict(sorted(ages.items(), key = lambda item: item[1]))
return list(sorted_ages)[0] + " is the youngest!"
ali_age, junaid_age = int(input("ali_age: ")), int(input("junaid_age: "))
print(yungest({"Ali": ali_age, "Junaid": junaid_age}))
Answer:
def yungest(ages):
def yungest(ages):if len(set(ages.values())) == 1:
def yungest(ages):if len(set(ages.values())) == 1:return "Same ages!"
def yungest(ages):if len(set(ages.values())) == 1:return "Same ages!"sorted_ages = dict(sorted(ages.items(), key = lambda item: item[1]))
def yungest(ages):if len(set(ages.values())) == 1:return "Same ages!"sorted_ages = dict(sorted(ages.items(), key = lambda item: item[1]))return list(sorted_ages)[0] + " is the youngest!"
def yungest(ages):if len(set(ages.values())) == 1:return "Same ages!"sorted_ages = dict(sorted(ages.items(), key = lambda item: item[1]))return list(sorted_ages)[0] + " is the youngest!"ali_age, junaid_age = int(input("ali_age: ")), int(input("junaid_age: "))
def yungest(ages):if len(set(ages.values())) == 1:return "Same ages!"sorted_ages = dict(sorted(ages.items(), key = lambda item: item[1]))return list(sorted_ages)[0] + " is the youngest!"ali_age, junaid_age = int(input("ali_age: ")), int(input("junaid_age: "))print(yungest({"Ali": ali_age, "Junaid": junaid_age}))