找到年龄最大的人,并输出

#如果是列表:
l1 = [1,2,3,4]
print(max(l1))

#如果是字典法一:
dict1 = {
     "zhagn":18,"li":20,"wang":22}
value = dict1.values()
print(max(value))
法二:
person = {
     "li": 18, "wang": 50, "zhang": 20, "sun": 22}
m = 'li'
for key in person.keys():
    if person[m] < person[key]:
        m = key

print(f'{m}\t{person[m]}')

#字符串排序。
str1 = input('input string:')
str2 = input('input string:')
str3 = input('input string:')
print(str1, str2, str3)

if str1 > str2:
    str1, str2 = str2, str1
if str1 > str3:
    str1, str3 = str3, str1
if str2 > str3:
    str2, str3 = str3, str2

print('after being sorted.')
print(str1, str2, str3)

你可能感兴趣的:(python题库)