0
<0xのでの関数>私は新しい機能を書いて、私はそれを実行すると、私はエラーを取得:Pythonの出力
<function read_grades at 0x000001F69E0FC8C8>
[OK]をので、ここでは私のコードです:
def add(x, y):
z = x/y * 100
return z
def calc_grade(perc):
if perc < 50:
return "1"
if perc < 60:
return "2"
if perc < 75:
return "3"
if perc < 90:
return "4"
if perc >= 90:
return "5"
def calc_command():
num1 = input("Input your points: ")
num2 = input("Input maximum points: ")
num3 = add(float(num1), float(num2))
grade = calc_grade(num3)
print("This is your result:", str(num3) + "%")
print("Your grade:", grade)
save = open("grades.txt", "r")
read_grades = save.read()
save = open("grades.txt", "w")
save.write(read_grades + grade)
save.close()
def read_grades():
save = open("grades.txt", "r")
read_grades = save.read()
grades = read_grades.split()
save.close()
return grades
while True:
command = input("Input your command: ")
if command == "CALC":
calc_command()
elif command == "EXIT":
break
elif command == "GRADES":
print(read_grades)
elif command == "HELP":
print("These are the commands:\nCALC - Calculates your grade and writes in the file.\nEXIT - Exits the program.\nGRADES - Reads your previous grades.\nHELP - This command. It helps you.")
else:
print("You inputed an invalid command. Type HELP for help.")
このread_grades()関数またはGRADESコマンドを実行するとエラーが発生します。この質問をマーク人のために
:私はいくつかの検索を行なったし、私はそのポストを見つけられませんでしたし、今私は、ランタイムエラーではありません答え
うん、私はあなたにスペースなしで文字列を区切るんどのように印刷への復帰を変更しなければならなかったが、ありがとうございましたし、別の質問あなたの関数名と競合変数名を使用しないことです昏睡と空白または配列の文字列? – 1234filip
@ 1234filip文字列を分割することについてのこの質問は、現在の質問とは関係がありません! _thorough_検索の後で答えが見つからない場合は、新しい質問をしてください。しかし、それよりも説明して、典型的な入力と予想される出力で説明する必要があります。 –
Okインターネットで検索しますkk – 1234filip