-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathX_velocity_formula.py
More file actions
28 lines (23 loc) · 1.11 KB
/
Copy pathX_velocity_formula.py
File metadata and controls
28 lines (23 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Programa para calcular la velocidad, distancia o tiempo
# Escribimos info sobre la funcion
def calc_velocidad(distancia, tiempo):
return distancia / tiempo
if __name__ == "__main__": # Si utilizamos funciones
print("Programa para calcular la velocidad, distancia y tiempo")
# Preguntamos al usuario que es lo que quiere calcular
answer = input("Que quieres calcular velocidad, distancia o tiempo? (v, d, t)")
if answer.upper() == "V":
distancia = float(input("Introduce valor distancia: "))
tiempo = float(input("introduce cuantos segundos: "))
velocidad = calc_velocidad(distancia, tiempo)
print(velocidad)
elif answer.upper() == "T":
distancia = float(input("Introduce valor distancia: "))
velocidad = float(input("Introduce valor velocidad: "))
tiempo = distancia / velocidad
print(tiempo)
elif answer.upper() == "D":
velocidad = float(input("Introduce valor velocidad: "))
tiempo = float(input("introduce cuantos segundos: "))
distancia = velocidad / tiempo
print(distancia)