Python 新手这个模运算符我做错了什么?我收到语义错误

问题描述

我是 Python 和一般编码的新手。三周前开始学习Python,两天前开始学习HTML。

我制作了这个程序。请不要介意 GPA 和 SAT 的任意截止。这纯粹是为了练习,并不是真正的大学招生建议。

#New program to guide high school students applying to college

print("Welcome to my college guidance program.")
name=input("To start,please write your name.\n")
name=str(name)

print("Hello",name)

print("Now,tell me what your GPA is.")
GPA=input("What is your unweighted GPA? Round to the nearest hundredth,please.\n")


try:
  GPA=float(GPA)
  if GPA%0.01!=0 or GPA%0.1!=0:
    print("Please round to the nearest hundredth place.")
    #THIS IS WHERE I'M GETTING INTO TROUBLE. I want this to print *only* if the user inputs something like 3 (instead of 3.0) or 2.98943424. Yet,if I write 3.33 or 2.75,this prints anyway. What am I doing wrong?
  if GPA>=3.5 and GPA<=4.0:
    print("You have an excellent GPA.")
  elif GPA>=3.0 and GPA<3.5:
    print("You have a good GPA.")
  elif GPA>=2.0 and GPA<3.0:
    print("Your GPA isn't the best but you should still be able to get into a college somewhere.")
  elif GPA>4.0:
    print("Only your unweighted GPA,please.")
  else:
    print("Your GPA is pretty bad. Fear not,you can still go to community college,and there's nothing wrong with that.")
 #If the user inputs something that's not rounded to the nearest hundredth,I want the program to start over and ask them their GPA again. How can I do that?
except:
  print("Only type in numbers,please.")
finally:
  print("Remember,you are more than just a number!")

 #if the user inputs something other than a number,or something that isn't divisible by 0.01 or 0.1,I want the program to ask again their GPA.

print("Okay! Now,tell me about your SAT score. Only your composite score,not the three individual subsections.")
SAT=input("What is your SAT score?")
try:
  SAT=int(SAT)
except: 
  print("Only numbers,please.")

 #Why does the program stop running here?    

  try:
    if SAT%10!=0:
      print("Remember,the SAT only goes up in increments of 10.") 
      #Same thing as above! I *only* want this to print if the user puts something like 2199. As of right Now,if the user writes something like 2199 or anything like that,the program just stops.
    elif SAT>=2100 and SAT<=2400:
      print("That's an excellent score.")
    elif SAT>=1800 and SAT<2100:
      print("That's a good score.")
    elif SAT>=1500 and SAT<1800:
      print("That's a decent score.")
    elif SAT<1500:
      print("The score is a little bit low.")
    

  except:
    print("Only numbers,please.")
    

在此先感谢您!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)