提问人:average npc 提问时间:11/18/2023 最后编辑:William Milleraverage npc 更新时间:11/21/2023 访问量:52
在 python 中获取 TypeError: '>' not supported between 'str' and 'int' [closed]
Getting a TypeError: '>' not supported between instances of 'str' and 'int' in python [closed]
问:
我在尝试编写程序时遇到了这个错误,无论我做什么,它都不会消失。关于如何解决这个问题的任何建议?
# This code will serve as the basis of a school grading system
# Task 1
# First we will implement the arrays we are going to use in our
# program along with all the variables/constants we shall need
ClassSize = 10
SubjectNo = 4
"StudentName" == ["Thomas", "Emily", "Mary", "Thomas", "Bob",
"Jacob", "James", "Ali", "Fatime", "Raj"]
"StudentMark" == [[55, 35, 20, 60],
[60, 70, 45, 45],
[60, 45, 35, 20],
[45, 38, 61, 47],
[69, 52, 31, 68],
[23, 42, 63, 28],
[70, 68, 59, 62],
[43, 23, 54, 67],
[70, 70, 70, 70],
[65, 43, 70, 23]]
index_variable = "Student name"
element = "StudentMark"[index_variable]
"distinction" == 0
"merit" == 0
"Pass" == 0
"Fail" == 0
"Subject high" == 70
"Suject low" == 0
"Total per student" == 0
# Task 2
# Here we will write the code that actually calculates
# the grades and the averages and percentages
"StudentName" == str(input("Enter a name: "))
if "Studentmark" == "70":
grade = "distinction"
"distinction" == "distiction" + "1"
elif "Studentmark" > "55":
grade = "merit"
"merit" == "merit" + "1"
elif "Studentmark" > "40":
grade = "Pass"
"Pass" == "Pass" + 1
else: grade = "Fail" and "Fail" == Fail + 1
答: 暂无答案
评论
"Studentmark"
是字符串,而不是变量名称==