Python选择题? 2020python二级题库
Python设计选择题
# python版本:3.6.5
def main():
# 保存题目
questions=["Q1","Q2","Q3","Q4","Q5"]
# 保存每个题目的四个答案
answers=[["A1","A2","A3","A4"],["A1","A2","A3","A4"],["A1","A2","A3","A4"],["A1","A2","A3","A4"],["A1","A2","A3","A4"]]
# 保存每个题目的正确答案
correctAswers=["A","B","C","A","B"]
# 保存四个选项
index=["A","B","C","D"]
# 当前题目序号
currentQuestion=0;
# 分数
point=0;
# 一共五道题
while (currentQuestion<5):
print("题目:",questions[currentQuestion])
for i in range(0,4):
print(index[i],".",answers[currentQuestion][i])
userAnswer = input("你的答案:")
# 默认abcd和大写一样,答对加分
if userAnswer.lower()==correctAswers[currentQuestion].lower():
point+=1
# 下一题
currentQuestion+=1
print("答题结束,你的分数:",point)
main()
python选择题/简答题
1. True的选项是A
2. True的选项是A
3. 输出是16 range(2,10)>2,3,4,5,6,7,8,9 循环了3次,X分别为2,3,4
4. 输出的结果是(-2,3,5)
5. people = [{'name': 'Mary', 'height': 160},{'name': 'Isla', 'height': 80},
{'name': 'Sam'}]
height=0
n=0
for i in range(len(people)):
if isinstance((people[i].get('height')),int):
n=n+1
height=people[i].get('height')+ height
else:
print('人员的平均身高为%s'% (height/n))
python选择题
由于时间关系,以下答案不能保证正确,仅供参考:6.C 7.A 8.C 9.D 10.D
Python常用数据类型的选择题
如果你看教材了,python没有这些数据类型
选D