Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- grades = []
- # Obtendo as notas do usuário
- try:
- for i in range(4):
- grade = float(input(f"Digite a {i+1}ª nota: "))
- if grade < 0 or grade > 10:
- raise ValueError("A nota deve estar entre 0 e 10.")
- grades.append(grade)
- except ValueError as e:
- print(f"Entrada inválida: {e}")
- exit()
- # Dividindo as notas por 2 e imprimindo os resultados
- print("Notas divididas por 2:")
- for i, grade in enumerate(grades, 1):
- half_grade = grade / 2
- print(f"{i}ª nota: {half_grade}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement