Advertisement
xickoh

ASI TP2

Oct 21st, 2021
995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. #Exercício 1
  2.  
  3. idades = [16, 18, 10, 28, 24, 26, 30, 46, 72, 65, 91]
  4.  
  5. print(f"A pessoa mais nova tem {min(idades)} anos e mais velha tem {max(idades)}")
  6. print(f"A média é {round(sum(idades)/len(idades),1)}")
  7.  
  8. #Exercício 2
  9.  
  10. notas = [8,7,6,10,12,14,12,18,12,17]
  11.  
  12. for nota in notas:
  13.     print(f"A nota {nota} ocorre {notas.count(nota)}x")
  14.  
  15. #Exercício 3
  16.  
  17. from datetime import date, datetime
  18.  
  19. bday = "03/12/1996"
  20. bday = datetime.strptime(bday, '%d/%m/%Y')
  21.  
  22. today = date.today()
  23. age = today.year - bday.year - ((today.month, today.day) < (bday.month, bday.day))
  24.  
  25. if age <= 12:
  26.     print("criança")
  27. elif age < 18:
  28.     print("juvenil")
  29. elif age < 65:
  30.     print("adulto")
  31. else:
  32.     print("senior")
  33.  
  34. #Exercício 4
  35.  
  36. import json
  37.  
  38. pt_eng = {}
  39. pt_eng["filme"] = ["film, movie"]
  40. pt_eng["locomotiva"] = ["locomotive, train"]
  41. pt_eng["pessoa"] = ["person, individual"]
  42.  
  43. print(json.dumps(pt_eng,indent=4))
  44.  
  45. print(pt_eng["locomotiva"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement