我们应该制作一个日程安排程序,您可以在其中输入日期,程序会返回您的日程安排。每天都有自己的时间表(周一和周三共享相同)。我只参加了这门 Python 课程 2 周,所以我们只知道基础知识。我怎样才能把它归结为更少的代码?
我的教授告诉我将所有这些 if 语句结合起来使用一个打印函数而不是七个。我通过定义 if 语句之前的天数来缩短它,但我不知道如何将它归结为一个打印命令
sunday = "Just talmud today"
monWed = "Talmud \nComputing Theory"
tuesday = "Talmud Klali \nIntro To Programming \nHistory \nEnglish Composition II"
thursday = "Shiur \nIntro To Programming \nHistory \nEnglish Composition II"
friday = "Lecture"
saturday = "Get off the computer!"
print("Welcome to your calendar")
dayOfWeek = input("What day is it? ")
dayOfWeek = dayOfWeek.lower()
if dayOfWeek == "sunday":
print(sunday)
elif dayOfWeek == "monday":
print(monWed)
elif dayOfWeek == "wednesday":
print(monWed)
elif dayOfWeek == "tuesday":
print(tuesday)
elif dayOfWeek == "thursday":
print(thursday)
elif dayOfWeek == "friday":
print(friday)
elif dayOfWeek == "saturday":
print(saturday)
else:
print("Check your spelling and try again")
慕田峪7331174
临摹微笑
开心每一天1111
相关分类