Write a Python program to receive two numbers from the user, and print the results of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Python program to receive two numbers from the user, and print the results of their multiplication. Two important issues: You must name your code file multiplier.py. • The input and output format of your programs must be identical to the examples provided in Table 1. Input Two numbers will be given to your program -as user input- in one line, separated from each other by a space. To take the user multiple inputs in one line use the following line of code: x, y input ().split() Input 11 3-1 80 -4-22 = Output You should simply print the result of multiplication in the output. Table 1: Samples of Provided Inputs and Expected Outputs Output -3 0 88 Task 4 ● ● ● Improve this program! The user should only be able to enter sensible numeric values for temperatures in Celsius (e.g., 4.7, -10, 143.5). Start by adding the following code to the top of your program. I'll go through it in more detail later in the course. Note: if copying from a PDF viewer, the indentation levels may not get copied correctly. If this happens, be sure to manually add the indentation levels (4 spaces per level). def isfloat(num): try: float(num) return True except ValueError: return False The above code will enable you to check if a given string is a float value, by writing, e.g., isfloat(celsius). Now, modify your code from Task 3, using the isfloat(...) function to make sure that the user has entered a value between, say, -200 and 200. If the value is valid, the program continues and converts the value to Fahrenheit as before. Otherwise, the program should tell the user that their value was invalid, and should prompt them for a new one. If you're doing this with an if-else block, it will only check once whether the value is valid. For bonus points, try to have the program repeat the check until the user enters a valid value. Hint: the best approach will include a while loop. See the below articles: W3Schools - Python While Loops Programiz – Python while Loop Write a Python program to receive two numbers from the user, and print the results of their multiplication. Two important issues: You must name your code file multiplier.py. • The input and output format of your programs must be identical to the examples provided in Table 1. Input Two numbers will be given to your program -as user input- in one line, separated from each other by a space. To take the user multiple inputs in one line use the following line of code: x, y input ().split() Input 11 3-1 80 -4-22 = Output You should simply print the result of multiplication in the output. Table 1: Samples of Provided Inputs and Expected Outputs Output -3 0 88 Task 4 ● ● ● Improve this program! The user should only be able to enter sensible numeric values for temperatures in Celsius (e.g., 4.7, -10, 143.5). Start by adding the following code to the top of your program. I'll go through it in more detail later in the course. Note: if copying from a PDF viewer, the indentation levels may not get copied correctly. If this happens, be sure to manually add the indentation levels (4 spaces per level). def isfloat(num): try: float(num) return True except ValueError: return False The above code will enable you to check if a given string is a float value, by writing, e.g., isfloat(celsius). Now, modify your code from Task 3, using the isfloat(...) function to make sure that the user has entered a value between, say, -200 and 200. If the value is valid, the program continues and converts the value to Fahrenheit as before. Otherwise, the program should tell the user that their value was invalid, and should prompt them for a new one. If you're doing this with an if-else block, it will only check once whether the value is valid. For bonus points, try to have the program repeat the check until the user enters a valid value. Hint: the best approach will include a while loop. See the below articles: W3Schools - Python While Loops Programiz – Python while Loop
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
On December 31, 2022, Akron, Incorporated, purchased 5 percent of Zip Company's common shares on the open market in exchange for $16,050. On December 31, 2023, Akron, Incorporated, acquires an...
-
2. A portfolio is composed of two stocks. The proportion of each stock, their expected values, and standard deviations are listed next. Stock 1 2 Proportion of portfolio 0.30 0.70 Mean 0.12 0.25...
-
7. Answer the questions below using the following information on stocks A, B, and C. A B C Expected Return 20% 21% 10% Standard Deviation 12% 10% 10% Beta 1.8 2.2 0.8 Assume the risk-free rate of...
-
1.think about the evolution of the food industry, What was it in the past, and what will it be in the future? How will the 4 p's of marketing evolve within the industry you selected? 2.What is one...
-
How far must the mirror M2 (see Fig. 35.20) of the Michel-son interferometer be moved so that 1800 fringes of He-Ne laser light ( = 633nm) move across a line in the field of view?
-
Suppose you were going to design a front door and doorway to fit snugly enough to keep out the drafts, yet to be easy to open. (You are not showing off precision carpentry here, but merely designing...
-
Develop a structured and an unstructured questionnaire to measure the importance of online retail shopping for working mothers. Distribute a copy of each to 10 different individuals and compare your...
-
Jennifer Willis worked for Coca Cola Enterprises, Inc. (CCE), in Louisiana as a senior account manager. On a Monday in May 2003, Willis called her supervisor to tell him that she was sick and would...
-
The following topology is set for OSPF dynamic routing protocol. What is the router ID for R2? SW1 LoopBack IP address: 5.5.5.5 192.168.20.15/24 20.20.20.5/24 R1 30.40.50.1/24 192.168.20.10/24 R3...
-
Part One: In 2015, Fran Lexa opened Fran's Flowers, a small shop selling floral arrangements. On December 31, 2016, her accounting records show the following: Sales revenue...
-
Use the following function to answer questions (a) and (b) below 4-x, x <3 x+2, x>3 f(x) = { (a) Find lim f(x) and lim f(x) Select the correct choice below and fill in any answer box(es) in your...
-
Read the following before proceeding Case study assessments that follow use Xero. Use a free or paid version of this software to complete the relevant assessments. o If you are using the free trial...
-
What are the different types of proprietary funds? Use your CAFR to discuss the proprietary funds used by your chosen government. Do any of these funds use exchange transactions? What financial...
-
discuss this question: what do you perceive to be the purpose and role of Accounting? How is accounting information potentially relevant to you in your area of business? After posting your response,...
-
A five-year $100 par value step-up note pays coupons semi-annually and has the following coupon rate structure: the annual coupon rate is 4% in year 1, which then rises by 50 bps every year over the...
-
Discuss, in detail, the differences between classified information and unclassified information. Additionally, provide a detailed explanation of the different types of unclassified information.
-
Which of the statements below does NOT describe antigens? Select one: A. Antigens exhibit immunogenicity and reactivity. B. Bacteria and viruses can have multiple antigens. C. Antigens can include...
-
Les has collected stamps in his spare time for years. He purchased many of his stamps at a price much lower than the current market value. Les recently lost his job as a carpenter. Since his wife...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-6. On December 12, Irene purchased the building where her store is located. She paid...
-
Clifford Johnson has a limited partnership investment and a rental condominium. Clifford actively manages the rental condominium. During 2012, his share of the loss from the limited partnership was...
-
Lisa Sizemore, a taxpayer in the 10-15 percent tax bracket, purchased stock as an investment on July 11, 2011. She sold the stock on July 9, 2012, 2 days before qualifying for the long-term holding...
-
The codon change (Gly-12 to Val-12) in human H-ras that converts it to oncogenic H-ras has been associated with many types of cancers. For this reason, researchers would like to develop drugs to...
-
Outline the general strategy used in metagenomics.
-
You need to understand the approach described in question 3 in More Genetic TIPS before answering this question. A muscle-specific gene was cloned and then subjected to promoter bashing. As shown...
Study smarter with the SolutionInn App