Advertisement
Rnery

média...

May 25th, 2024 (edited)
728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | Source Code | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. grades = []
  5.  
  6. # Obtendo as notas do usuário
  7. try:
  8.     for i in range(4):
  9.         grade = float(input(f"Digite a {i+1}ª nota: "))
  10.         if grade < 0 or grade > 10:
  11.             raise ValueError("A nota deve estar entre 0 e 10.")
  12.         grades.append(grade)
  13. except ValueError as e:
  14.     print(f"Entrada inválida: {e}")
  15.     exit()
  16.  
  17. # Dividindo as notas por 2 e imprimindo os resultados
  18. print("Notas divididas por 2:")
  19. for i, grade in enumerate(grades, 1):
  20.     half_grade = grade / 2
  21.     print(f"{i}ª nota: {half_grade}")
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement