while循环测试题2

while循环测试题2

这是一道Python新手略微抓狂的题目

下面这道程序是对学生学习情况的调研问卷,但是其中有部分关键的语句被屏蔽了,聪明的读者,请你拿上武器,戴上头盔,骑上骏马,勇敢地去迎接挑战吧!

(使用读心术将横线处的语句补充完整,O(∩_∩)O)

# -*- coding: utf-8 -*-

"""
作业3:学习调研系统
"""

# 定义一个函数,并在主函数中调用它
def study_investigation():
    while ______:     # 外层使用while循环,当出错时进入下一层循环
        anwser_1st = input("Have you studied recently?y/n': ")
        if anwser_1st.lower() == 'y':
            print("Very good!And which subject have you studied?")
            print("1.Python", "2.Java", "3.Exit", sep = "\n")
			print("Please choose 1, 2, 3 for each selection.")
            anwser_2nd = input("Choose the subject please:")
            if anwser_2nd not in ("1", "2", "3"):
                print("Input wrong!Please do it again.")
                ______
            else:
                if anwser_2nd == "1":
                    print("Wow! Learning Python is a good idea!")
                    _______
                elif anwser_2nd == "2":
                    print("Em..Learning Java is a little difficult.")
                    _______
                else:
                    print("You have exited the study investigation")
                    _______
        elif anwser_1st.lower() == 'n':
            print("You need hard-working to get improved!")
            _______
        else:
            print("Input wrong!Please do it again.")
            print()
            _______

if __name__ == "__main__":
    study_investigation()

好吧,完整的代码在这里:

# -*- coding: utf-8 -*-

"""
作业3:学习调研系统
"""

# 定义一个函数,并在主函数中调用它
def study_investigation():
    while True:     # 外层使用while True循环,当出错时进入下一层循环
        anwser_1st = input("Have you studied recently?y/n': ")
        if anwser_1st.lower() == 'y':
            print("Very good!And which subject have you studied?")
            print("1.Python", "2.Java", "3.Exit", sep = "\n")
			print("Please choose 1, 2, 3 for each selection.")
            anwser_2nd = input("Choose the subject please:")
            if anwser_2nd not in ("1", "2", "3"):
                print("Input wrong!Please do it again.")
                continue
            else:
                if anwser_2nd == "1":
                    print("Wow! Learning Python is a good idea!")
                    break
                elif anwser_2nd == "2":
                    print("Em..Learning Java is a little difficult.")
                    break
                else:
                    print("You have exited the study investigation")
                    break
        elif anwser_1st.lower() == 'n':
            print("You need hard-working to get improved!")
            break
        else:
            print("Input wrong!Please do it again.")
            print()
            continue

if __name__ == "__main__":
    study_investigation()

你可能感兴趣的:(Python核心编程,编程语言,python)