Mundo em Python

Fórmula Básica da Balística

import math

g = 9.8

escolha = True
while escolha:
print("\n")
print("="*60)
print("\t\t\tFórmula Básica da Balística")
print("=" * 60)
print("""
1. Posição Horizontal (x) e Posição Vertical (y)
2. Alcance Máximo (R)
3. Altura Máxima (H)
4. Tempo de Voo (T)
0. Exit/Quit/Saída
""")
escolha = input("Escolha uma opção: ") if escolha == "1":
angulo = float(input("Digite ângulo (em graus): "))
v0 = float(input("Velocidade inicial em m/s: "))
t = int(input("Tempo após o disparo em Segundos: "))
theta = math.radians(angulo)
x_t = v0 * math.cos(theta) * t
y_t = v0 * math.sin(theta) * t - 0.5 * g * t ** 2

print(f"Posição Horizontal (x): {x_t:.2f} m")
print(f"Posição Vertical (y): {y_t:.2f} m") elif escolha == "2":
v0 = float(input("Velocidade inicial em m/s: "))
angulo = float(input("Digite ângulo (em graus): "))
theta = math.radians(angulo)
alcance_maximo = (v0 ** 2 * math.sin(2 * theta)) / g
print(f"Alcance Máximo: {alcance_maximo:.2f} m") elif escolha == "3":
v0 = float(input("Velocidade inicial em m/s: "))
angulo = float(input("Digite ângulo (em graus): "))
theta = math.radians(angulo)
altura_maxima = (v0 ** 2 * math.sin(theta) ** 2) / (2 * g)
print(f"Altura Máxima: {altura_maxima:.2f} m") elif escolha == "4":
v0 = float(input("Velocidade inicial em m/s: "))
angulo = float(input("Digite ângulo (em graus): "))
theta = math.radians(angulo)
tempo_voo = (2 * v0 * math.sin(theta)) / g
print(f"Tempo de Voo: {tempo_voo:.2f} s") elif escolha == "0":
print("\n Adeus")
escolha = False

else:
print("\n Escolha não válida.\n Tente outra vez.")
0