Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # Script que pide una distancia en kms y un tiempo en hs y devuelve la
- # velocidad. Usar funciones
- """
- distancia = int(input("Ingrese la distancia: "))
- tiempo = int(input("Ingrese el tiempo: "))
- velocidad = distancia/tiempo
- print(f"La velocidad buscada es {velocidad:.1f} km/h")
- """
- def ingresar_dato(dato):
- return int(input(f"Ingrese {dato}: "))
- def calcular_velocidad(d,t):
- return d/t
- def imprimir(v):
- print(f"La velocidad buscada es {v} km/h")
- distancia = ingresar_dato("distancia")
- tiempo = ingresar_dato("tiempo")
- velocidad = calcular_velocidad(distancia, tiempo)
- imprimir(velocidad)
Advertisement
Add Comment
Please, Sign In to add comment