I can not concatenate this

-1

To obtain certain statistics of a route, it is requested to realize a program that given a distance, deliver the speed in kilometers per hour and in meters per second. For this, there are two time and distance variables that come in seconds and kilometers respectively. Your program must save a string in the result variable, for example, for the following case:

time = 1

distance = 0.01

The result variable should have the following:

"The speed is 36.0 km / h or 10.0 m / s"

    
asked by Luis Adolfo Pacheco Silva 29.10.2018 в 23:17
source

1 answer

0

Understanding that what you are looking for is to concatenate the two variables that represent the speeds (For example: vel_1 and vel_2 ), then a possible solution:

#!/usr/bin/python
# -*- coding: utf-8 -*-

# tiempo en h
tiempo = 1

# distancia en Km
distancia = 0.01

# velocidad en Km/h
vel_1 = distancia / tiempo

# velocidad en m/s
factor = 0.277777777777778
vel_2 = vel_1 * factor

print('La velocidad es %s km/h o %s m/s' %(vel_1, vel_2))
    
answered by 29.10.2018 в 23:33