Answer the question
In order to leave comments, you need to log in
Why doesn't the Python code work?
Here is the code:
def calculate():
n = input("Кол-во учеников: ")
k = input("Кол-во яблок: ")
print("Кол-во яблок что получил кадлый ученик: "+k//n+"\n Кол-во яблок осталось: "+k%n)
calculate();
Кол-во учеников: Кол-во яблок:
Traceback (most recent call last):
File "./Playground/file0.py", line 6, in <module>
calculate();
File "./Playground/file0.py", line 3, in calculate
k = input("Кол-во яблок: ")
EOFError: EOF when reading a line
Answer the question
In order to leave comments, you need to log in
Because do not divide a number by a number, but a line by a line.
n = int(input("Number of students: ")) - you need to convert the string to a number.
So a little prettier:
def calculate():
n = int(input("Кол-во учеников: "))
k = int(input("Кол-во яблок: "))
print(f'Кол-во яблок что получил кадлый ученик: {k//n}')
print(f'Кол-во яблок осталось: {k%n}')
calculate();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question