Python经典基础编程练习题(二)——每日10题
1.编写一个程序,输入若干个单词,并且以逗号分隔按字母顺序排序后,以逗号分隔打印单词。输入:without,hello,bag,world,输出:bag,hello,without,world
解题思路:掌握分词和排序函数
- a=input(“请输入一串单词:”)
- list1=a.split(‘,’)
- list1.sort()
- print(‘,’.join(list1))
2.输入某年某月某日,判断这一天是这一年的第几天?
解题思路:注意判断闰年和输出格式 - year=int(input(‘请输入年:’))
- month=int(input(‘请输入月:’))
- day=int(input(‘请输入日:’))
- months = (0,31,59,90,120,151,181,212,243,273,304,334)
- if 1<= month <=12:
-
s=months[month-1]