python - 无法修复变量python
问题描述
所以我可以划分我之前问过的变量(谢谢)。但我想我没有输入足够的代码,所以这就是全部内容,我到处都遇到错误,但无论我改变什么来尝试修复它,我都会得到相同的响应。是的,我是 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')
**
解决方案
您可以使用 int 将字符串转换为整数。你只需要声明整数。这是一个例子
Tardies = int(“15”)
Absences = int(“5”)
real_absences = Tardies // 3 + Absences
推荐阅读
- python - 带有数据权重的 scipy.stats.mannwhitneyu 版本
- flutter - 如何在flutter上制作图标和文字翻译动画
- go - fyne GUI compile to Web Assembly failed
- javascript - 重新加载浏览器后,window.beforeunload 事件仍然在尝试存在页面时显示确认警报
- vue.js - Vuetify 数据表项。
未应用模板 - 但其他模板很好 - reactjs - 根据当前路径在 React Router 中设置活动链接
- r - 使用 R 中的数据集位置进行过滤
- python - 如何使用调试符号轻松安装 pywin32
- ios - 无效的苹果应用程序站点关联文件格式
- powershell - Powershell重命名文件,名称中间有序号