def compute_invigilated_mark():
"""Prints given name and family name with overall score"""
test = 0.15
exam = 0.60
first_name = input("Given names(s)? ")
last_name = input("Family name? ")
both_names = last_name.upper() + "," + first_name.title()
new_test_percent = float(input("Test percent? ")) * test
new_exam_percent = float(input("Exam percent? ")) * exam
overall_percent = new_test_percent + new_exam_percent
end_result = overall_percent / (exam + test)
print(both_names + end_result)
compute_invigilated_mark()
我想得到最终结果,例如:Bourne, Jason: 66.0
rrror消息:
builtins.TypeError:无法隐式地将'float'对象转换为str。
注意:我把它分开了,所以你可以更容易地阅读:)。
答案 0 :(得分:1)
both_names
是一个字符串,而end_result
是一个浮点数,但您正在尝试将它们连接起来(print(both_names + end_result)
)。
您应该将end_result
转换为字符串:
print(both_names + str(end_result))