Professional Documents
Culture Documents
Palabras
Palabras
Luis Julio5:06
II (15 Points)
In main function the user is asked to enter distance traveled and time and then
send this information to a Python function that calculates and returns the speed of
a car. The function will need to have parameters for distance traveled and time
taken for the travel. The speed is calculated as:
In the main function show how to call this function in a print statement.
***********************************************************************************
***
def principalFunction(distanceTravel, time):
//Pide los datos y los cambia a float para poder hacer la division
distanceTravel = float(input("Please enter the distance: "))
time = float(input("Please enter the time: "))
speed = SpeedFunction(distanceTravel,time)
//Imprime la velocidad ya calculada
print("The speed is: " + str(speed))
c = 0
d = 0
principalFunction(c,d)
***********************************************************************************
****
Write code using Python. Make sure that the code is well commented to explain what
your steps are doing. Write a program that asks user to enter a number between 2 -
9. If the user enters any number that is not between 2 and 9 then you must give the
message "Incorrect Input" and stop the program. If the number is between 2 and 9
then display tables of that number 1 to 10 as indicated below:
For example if the user enters 3 the output should look like:
Table of 3 is: 3 6 9 1
Table of 3 is: 3 6 9 12 15 18 21 24 27 30
***********************************************************************************
*******
cond = True
while cond == True:
a = int(input("Ingrese un numero entre 2 y 9: "))
if a < 2:
print("Entrada incorrecta")
cond = False
if a > 9:
print("Entrada incorrecta")
cond = False
else:
print("La tabla del "+str(a)+" es:", end ="")
for i in range(1,11):
z = a*i
print(z," ",end="")
print("\n")
***********************************************************************************
*****