Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- name = input()
- average_grade = 0
- break_point = 0
- counter = 1
- while counter <= 12:
- grade = float(input())
- if grade >= 4:
- average_grade += grade
- counter += 1
- else:
- break_point += 1
- if counter == 13:
- print(f'{name} graduated. Average grade: {average_grade / 12:.2f}')
- break
- if break_point == 2:
- print(f'{name} has been excluded at {counter} grade')
- break
- Решение с for:
- name = input()
- average_grade = 0
- break_point = 0
- for i in range(1, 14):
- grade = float(input())
- if grade >= 4:
- average_grade += grade
- else:
- break_point += 1
- if break_point == 2:
- print(f'{name} has been excluded at {i - 1} grade')
- break
- if i - break_point == 12:
- print(f'{name} graduated. Average grade: {average_grade / 12:.2f}')
- break
- Фундаменталс решение:
- name = input()
- grades = []
- while True:
- grades.append(float(input()))
- if len(list(filter(lambda grade: grade < 4, grades))) == 2:
- print(f"{name} has been excluded at {len(grades) -1} grade")
- break
- elif len(list(filter(lambda grade: grade >= 4, grades))) == 12:
- print(f"{name} graduated. Average grade:"
- f" {sum(list(filter(lambda grade: grade >= 4, grades))) / 12:.2f}")
- break
Add Comment
Please, Sign In to add comment