Write a program that accepts a whole number as input, multiplies that number by 12, and then outputs the product.
Hint: Remember that to think about the data type that the user will input. How can you make sure that their input is entered as a number?
Answers
Answered by
0
Thats s python script for u
Explanation:
def product():
num = int(input("enter here: "))
res = (num*12)
print(res)
product()
Answered by
0
A program that accepts a whole number as input, multiplies that number by 12, and then outputs the product.
Python Code
try:
a = int(input("Enter the number: " ))
print("Product (x12) = " + str(a * 12))
except:
print("Entered not a number")
- You can check a block of code for mistakes with the try block. You can deal with the mistake using the except block. When there is no error, you can run code using the else block. Regardless of the outcome of the try- and except blocks, you can still run code by using the finally block.
- Try and except are two Python functions that are used to manage exceptions (also known as execution errors). When using try and except, the process keeps going even if an exception occurs.
- We are unable to have the try block without the except block, therefore our only option is to try to catch the exception before it is raised and provide the pass statement in the except block as previously demonstrated. A line of code with no data is comparable to the pass statement. The finally block is an additional option.
#SPJ2
Similar questions