Question

In: Computer Science

multiply2nums should accept 2 values and return the product (answer you get when you multiply). greeting...

multiply2nums should accept 2 values and return the product (answer you get when you multiply).

greeting should accept one value and print an appropriate greeting using that value.

For example, if you sent "Steven" to the greeting function, it should print "Hello, Steven"

def main():
user = input("Please enter your name ")
greeting(user)
try:
num1 = int(input("Please enter an integer "))
num2 = int(input("please enter another integer "))
result = multiply2nums(num1,num2)
print("The product of your two numbers is ",result)
except:
print("Error found in input")


main()

Solutions

Expert Solution

CODE: Python Programming Language

def greeting(user):
print("Hello, {}".format(user))
def multiply2nums(num1, num2):
return num1 * num2
def main():
user = input("Please enter your name: ")
greeting(user)
try:
num1 = int(input("Please enter an integer: "))
num2 = int(input("Please enter another integer: "))
result = multiply2nums(num1, num2)
print("The product of your two numbers is", result)
except:
print("Error found in input")
main()

=======================================================================

SCREENSHOT OF THE CODE:

=======================================================================

OUTPUT:

Thank you. Please ask me if you have any doubt.


Related Solutions

In JAVA How can you multiply two matrices that are different lengths. the answer should be...
In JAVA How can you multiply two matrices that are different lengths. the answer should be in 3d array so [][][] how to multiply a 3d array with a 2d array and the result is in 3d array for example: double[][][] nums1 = { { {0.0, 0.1, 2.0}, {3.0,4.0,5.0} }, { {6.0,7.0,8.0}, {9.0,10.0,11.0} } } int [][] nums2 = { {1,2,3}, {4,5,6}, {7,8,9}} and the results should be in [][][] <-- in this dimension int[][][] answer = { {  {18, 21,24},...
What would you multiply "atoms of xenon" by to get the units "grams of xenon" ?...
What would you multiply "atoms of xenon" by to get the units "grams of xenon" ? atoms Xe = g Xe (number) (unit) (number) (unit) (number) (unit)
What are the values you get from "data[,1]" and "data[,2]" in r code? Are the values...
What are the values you get from "data[,1]" and "data[,2]" in r code? Are the values from "data[,1]" are the fitted values/ yhat values? When I try "fitted(data)" I get different values from "data[,1]", I am very confused.
1. What would you multiply "grams of copper" by to get the units "atoms of copper"...
1. What would you multiply "grams of copper" by to get the units "atoms of copper" ? g Cu = atoms Cu (number) (unit) (number) (unit) (number) (unit) (number) (unit) 2. What would you multiply "atoms of calcium" by to get the units "grams of calcium" ? atoms Ca = g Ca (number) (unit) (number) (unit) (number) (unit) (number) (unit)
For the molecular compound carbon tetrabromide, what would you multiply "molecules of CBr4" by to get...
For the molecular compound carbon tetrabromide, what would you multiply "molecules of CBr4" by to get the units "grams of CBr4"? For the molecular compound carbon dioxide, what would you multiply "molecules of CO2" by to get the units "grams of CO2"? How many ATOMS of carbon are present in 1.85 moles of carbon monoxide ? How many MOLES of oxygen are present in 3.38×1022 molecules of carbon monoxide ? How many GRAMS of sulfur are present in 2.60 grams...
Why you should be happy to get a tax refund, not guilty When it comes to...
Why you should be happy to get a tax refund, not guilty When it comes to be tax time, people love to start throwing around phrases that enrage me and make me wish to become a cartoon hero that points at someone and ejects a roll of duct tape towards their mouths to silence them. In my dreams, I would be a cross between Spiderman and a librarian. Anyway, how often have you heard this phrase? “If you get a...
2. If the values of x in problem range from 2 to 25, should you use...
2. If the values of x in problem range from 2 to 25, should you use this model to predict the mean value of y when x = a. 3 ? b. -3 ? c. 0 ? d. 24 ? 3. Fitting a straight line to a set of data yields the following prediction line: Y = 16 - .05x a. Interpret the meaning of y intercept, b0 b. Interpret the meaning of slope, b1 c. Predict the value for...
Why is Beta the correct measure of risk and why do you get more return when...
Why is Beta the correct measure of risk and why do you get more return when you can just diversify? Why do you get greater returns by bearing a greater risk when it comes to Beta stocks? What are the main criticisms of Effecient Market hypothesis? How can you take advantage of these criticism? How does it justify its claim and show evidence that doesnt support the capital asset pricing model?
(c) Auditors should accept some of the blame when a company on which they have expressed...
(c) Auditors should accept some of the blame when a company on which they have expressed an unmodified audit opinion subsequently fails, and they should also do more to highlight going concern problems being faced by a company. Required Discuss this statement.
Who get a performance appraisal? How do you get a performance appraisal? When when do you get a performance appraisal?
Who get a performance appraisal?How do you get a performance appraisal?When when do you get a performance appraisal?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT