teslariu

func2

Jul 15th, 2022
1,252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4.  
  5. # Script que pide una distancia en kms y un tiempo en hs y devuelve la
  6. # velocidad. Usar funciones
  7. """
  8. distancia = int(input("Ingrese la distancia: "))
  9. tiempo = int(input("Ingrese el tiempo: "))
  10.  
  11. velocidad = distancia/tiempo
  12. print(f"La velocidad buscada es {velocidad:.1f} km/h")
  13. """
  14. def ingresar_dato(dato):
  15.     return int(input(f"Ingrese {dato}: "))
  16.    
  17. def calcular_velocidad(d,t):
  18.     return d/t
  19.    
  20. def imprimir(v):
  21.     print(f"La velocidad buscada es {v} km/h")
  22.    
  23.  
  24. distancia = ingresar_dato("distancia")
  25. tiempo = ingresar_dato("tiempo")
  26. velocidad = calcular_velocidad(distancia, tiempo)
  27. imprimir(velocidad)
Advertisement
Add Comment
Please, Sign In to add comment