无法修复变量python

问题描述 投票:-2回答:2

因此,我能够对我之前询问的变量进行除法(谢谢)。但是我想我没有放入足够的代码,所以这就是整个问题,到处都是错误,但是无论我为修复它而进行的更改,我都得到相同的响应。是的,我是python的新手,这需要一个小时。

# grade: The student's grade level  Ex. 12
# first: 1st six-weeks grade    Ex. 98
# second: 2nd six-weeks grade   Ex. 78
# third: 3rd six-weeks grade    Ex. 89
# num_exemptions: The number of exemptions that the student has already applied for this semester.  Ex. 3
# absences: The number of absences that the student has accrued for the semester.   Ex. 4
# tardies: The number of tardies that the student has accrued for the semester.   Ex. 5
# previously_taken_exemptions: Has the student taken an exemption for the same course in the fall. Ex. True
print('Enter your 1st 6 weeks grade. Ex. 98')
first = input()
print('Enter your 2nd 6 weeks grade. Ex. 78')
second = input()
print('Enter your 3rd 6 weeks grade. Ex. 89')
third = input()
print('Enter the number of exemptions that you have already applied for this semester. Ex. 3')
num_exemptions = input()
print('Enter your grade. Ex. 12')
grade = input()
print('Enter how many absences you have had this semester. Ex. 4')
absences = input()
print('Enter how many times you have been tardy this semester. Ex. 5')
tardies = input()
print('Have you taken and exemption for this course in the fall. Ex. no')
previously_taken_exemptions = input()
real_absences = float(tardies) // 3 + float(absences)
first = int(first)
sum = float(first) + float(second) + float(third)
average = sum/3
if(average >= 81 and average <= 100):
    print("Your Grade is an A")
elif(average >= 61 and average <= 80):
    print("Your Grade is an B")
elif(average >= 41 and average <= 60):
    print("Your Grade is an C")
elif(average >= 0 and average <= 40):
    print("Your Grade is an F")
else:
    print("You did something wrong, try again")
if float(grade == '11') and float(num_exemptions) <= 2 and float(real_absences) <= 3 and float(previously_taken_exemptions) == 'no' and float(average) >= 84:
    print('You are eligable!')
elif float(grade == '12') and float(num_exemptions) <= 4 and float(real_absences) <= 3 and float(previously_taken_exemptions) == 'no' and float(average) >= 84:
    print('You are eligable!')
elif float(grade == '9' or '10') and float(num_exemptions) <= 1 and float(real_absences) <= 3 and float(previously_taken_exemptions) == 'no' and float(average) >= 84:
    print('You are eligable!')
else:
    print('You are not eligable')

**

python division
2个回答
0
投票

因为是字符串,所以使用:

real_absences = float(tardies) // 3 + float(absences)

0
投票

您可以使用int将字符串转换为整数。您只需要声明整数。这是一个例子

Tardies = int(“15”)
Absences = int(“5”)
real_absences = Tardies // 3 + Absences
© www.soinside.com 2019 - 2024. All rights reserved.