Python
Помогите пожалуйста решить задачу на питоне...
Вводя в цикле по 5 оценок каждого учащегося, подсчитать число студентов, имеющих хотя бы одну оценку 2, и имеющих все оценки 5.
# Initialize a counter for the number of students with at least one 2 grade
students_with_2 = 0
# Initialize a counter for the number of students with all 5 grades
students_with_all_5 = 0
# Set the number of students
num_students = 5
# Loop over the students
for i in range(num_students):
# Initialize a flag to track whether the student has at least one 2 grade
has_2 = False
# Initialize a flag to track whether the student has all 5 grades
has_all_5 = True
# Loop over the grades for this student
for j in range(5):
# Prompt the user to enter a grade
grade = int(input(f"Enter grade {j+1} for student {i+1}: "))
# Check if the grade is 2
if grade == 2:
has_2 = True
# Check if the grade is not 5
if grade != 5:
has_all_5 = False
# Check if the student has at least one 2 grade
if has_2:
students_with_2 += 1
# Check if the student has all 5 grades
if has_all_5:
students_with_all_5 += 1
# Print the results
print(f"Number of students with at least one 2 grade: {students_with_2}")
print(f"Number of students with all 5 grades: {students_with_all_5}")
Аслан Шонаев
Спасибо огромное!!!
a, b, c, d, e=map(int, input().split())
for I in дальше не знаю
for I in дальше не знаю
Похожие вопросы
- Помогите пожалуйста решить задачи на питоне:
- Помогите мне пожалуйста решить задачу на питоне!
- Помогите, пожалуйста, решить задачу Python
- Помогите, пожалуйста, с задачей на питоне!
- Помогите пожалуйста с задачей по питону
- Помогите пожалуйста с задачей на Питоне
- Помогите пожалуйста решить задачу "Ход конём" в Python.
- Помогите пожалуйста решить задачу по программированию наpython.
- Помогите пожалуйста решить задачу на python
- Добрый вечер, помогите, пожалуйста, решить задачу по информатике