题目
题目
多项填空题

Question at position 6 The code blocks below have been scrambled. The program should help the user decided what activity they do. If the user is tired, and its after 9pm, the user should play video games. If the user is tired, and its before 9pm, the user should take a nap. If the user is not tired, and its after 9pm, the user should cook dinner. If the user is not tired, and its before 9pm, the user should work out. Which of the following is the correct order of the code blocks?Top label: Code blocks:Code blocks:position 11[input]Position 1. Reorder Choice: time = 10tired = falsetime = 10tired = falseposition 22[input]Position 2. Reorder Choice: &nbsp; if time &lt; 9: &nbsp; &nbsp; &nbsp; &nbsp; print("work out") if time < 9: print("work out")position 33[input]Position 3. Reorder Choice: if tired:if tired:position 44[input]Position 4. Reorder Choice: else: &nbsp; print("play video games") else: print("play video games")position 55[input]Position 5. Reorder Choice: &nbsp; if time &lt; 9:&nbsp; &nbsp; &nbsp; &nbsp; print("take a nap") if time < 9: print("take a nap")position 66[input]Position 6. Reorder Choice: else:else:position 77[input]Position 7. Reorder Choice: &nbsp; else: &nbsp; &nbsp; &nbsp; &nbsp; print("cook dinner") else: print("cook dinner")Bottom label: null

选项
A.time = 10 tired = false
B.if tired:
C.if time < 9: prin
D.if time < 9: print("take a nap")
E.if tired:
F.else: print("play video games")
G.if time < 9: print("work out")
查看解析

查看解析

标准答案
Please login to view
思路分析
Here is a step-by-step walkthrough of the task and the given options, organized so you can see how each piece fits into the overall control flow. First, outline the intended logic from the prompt: If the user is tired, then depending on time, either nap or play video games. If the user is not tired, then depending on time, either work out or cook dinner. In code terms: - Initialize time and tired status. - If tired is true: - If time < 9, print "take a nap"; - Else, print "play video games". - If tired is false (the outer else): - If time < 9, print "work out"; - Else, print "cook dinner". Option-by-option analysis of the provided answer options: Option 1: time = 10\ntired = false Analysis: This is the initialization for the variables time and tired, establishing the starting state used by the rest of the blocks. It is a necessary first line and correctly sets time to 10 and tired to false, which places us in the outer else branch of the overall if-statement. By itse......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

类似问题

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!