Hi zusammen ich muss zu dieser Aufgabenstellung einen Python Code machen. Jedoch Habe ich einen Fehler denn beim 2. Test mit 3x der 1 gibt es einen falschen Input. Wie müsste der Code abgeändert werden damit es funktioniert ?
Aufgabe:
- A school decided to replace the desks in three classrooms. Each desk sits two students. Given the number of students in each class, print the smallest possible number of desks that can be purchased.
The program should read three integers: the number of students in each of the three classes, a, b and c respectively.
In the first test there are three groups. The first group has 20 students and thus needs 10 desks. The second group has 21 students, so they can get by with no fewer than 11 desks. 11 desks is also enough for the third group of 22 students. So we need 32 desks in total.
Run Test 1: Input: 20, 21, 22 ; Correct Answer: 32
Run Test 2: Input: 1, 1, 1 ; Correct Answer: 3
Code :
Eingabe1 = input("Anzahl Schueler 1")
Eingabe2 = input("Anzahl Schueler 2")
Eingabe3 = input("Anzahl Schueler 2")
Anzahl_S =(int(Eingabe1) + int(Eingabe2) + int(Eingabe3))
num = (int(Anzahl_S) /2 )
def check(num):
if num & 1 == 0:
print(int(num))
else:
print(int(num)+1)
check(int(num))