The following code should take a number as input, multiply it by 8, and print the result. In line 2 of the code below, the * symbol represents multiplication. Fix the errors so that the code works correctly: input ("Enter a number: ") print (num * 8)

Respuesta :

Answer:

The correct program is as follows:

num = float(input ("Enter a number: "))

print(num * 8)

Explanation:

Notice the difference between (1)

num = float(input ("Enter a number: "))

print (num * 8)

and (2)

input ("Enter a number: ")

print(num * 8)

Program 1 is correct because:

- On line 1, it takes user input in numeric form, unlike (2) which takes it input as string

- On line 2, the program multiplies the user input by 8 and prints it out

ACCESS MORE
EDU ACCESS
Universidad de Mexico