Python 练习实例31

  • 时间:
  • 浏览:32
题目:请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续判断第二个字母。

程序分析:用情况语句比较好,如果第一个字母一样,则判断用情况语句或if语句判断第二个字母。。

程序源代码:

实例

#!/usr/bin/Python# -*- coding: UTF-8 -*-letter = raw_input("please input:")#while letter != 'Y':ifletter == 'S': print('please input second letter:')letter = raw_input("please input:")ifletter == 'a': print('Saturday')elifletter == 'u': print('Sunday')else: print('data error')elifletter == 'F': print('Friday')elifletter == 'M': print('Monday')elifletter == 'T': print('please input second letter')letter = raw_input("please input:")ifletter == 'u': print('Tuesday')elifletter == 'h': print('Thursday')else: print('data error')elifletter == 'W': print('Wednesday')else: print('data error')

以上实例输出结果为:

 please input:S please input second letter: please input:a Saturday