题目为灰色,记录和过程为其他。
0. 请问下面代码是打印 "YES" 还是 "NO"?)
if 'FishC' == "fishc":
print("YES")
else:
print("NO")
初见时的疑惑点:条件分支语句:if-条件为真执行的操作(if是判断而不是断定,是根据if判断T&F再决定是否进行else的操作及最后的print)。else-条件为假执行的操作。
1. 请问下面代码会打印多少个 "Yo~"?b
yoo = 222
while yoo < 233:
print("Yo~")
2. 请问下面代码会打印多少个 "Man"?
while 1 + 1 == 2:
print("Man")
❤ while条件:如果条件为真就会一直执行(无限循环)
3. 请问下面代码存在什么问题?
age = input("请输入你的年龄:")
if age <= 18:
print("你已经成年^o^")
else:
print("对不起,你还未成年T_T")
这个题目让我想了还蛮久,我觉得是在≤上,但这不是跟执行有关的问题。问题出现在没有建立临时文件temp,即
temp = input(a)
age = int(temp)
temp=input是需要录入一个值得,age=int(temp)是由于temp录入的是字符串,需要转成和猜的数一样的类型。
5. 请阅读下面代码,根据你的理解,代码中问号(???)处应该填写什么内容?
x = input("请输入一个数字:")
x = int(x)
if x > 20:
print("大于20")
else:
if x < 10:
print("小于10")
else:
print("???")
0. 编写一个成绩评级程序,要求用户输入分数,程序返回对应的评级。
- 分数 < 60,D
- 60 <= 分数 < 80,C
- 80 <= 分数 < 90,B
- 90 <= 分数 < 100,A
- 分数 == 100,S
-
temp = input("请输入分数:") score = int(temp) if score == 100: print("S") else: if 90 <= score < 100: print("A") else: if 80 <= score < 90: print("B") else: if 60 <= score < 80: print("C") else: if score < 60: print("D")
1. 修改上一题的代码,让程序可以不断接收输入,直至用户输入小写字母 e 结束程序。(这题答案是搜的 我也不会)题目
temp = '' while True: temp = input("请输入你的分数:") if temp != 'e': temp = int(temp) if temp < 60: print("D") elif 60 <= temp < 80: print("C") elif 80 <= temp < 90: print("B") elif 90 <= temp < 100: print("A") elif temp == 100: print("S") else: print("继续加油哦!") break