Three variables, x, y, and z, supposedly hold strings of digits, suitable for converting to integers....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Three variables, x, y, and z, supposedly hold strings of digits, suitable for converting to integers. Write code that converts these three variables to integers and print the sum of these three integers. However, if any variable has a value that cannot be converted to an integer, display the string "bad value (s) in: "followed by the names of the variables that have bad values (separated by spaces, in alphabetically ascending order). For example, if the values of x, y, and z were respectively "3", "9", and "2" then the number 14 would be displayed; but if the values were "abc", "15", and "boo" then the output would be: Three variables, x, y, and z, supposedly hold strings of digits, suitable for converting to integers. Write code that converts these three variables to integers and print the sum of these three integers. However, if any variable has a value that cannot be converted to an integer, display the string "bad value (s) in: "followed by the names of the variables that have bad values (separated by spaces, in alphabetically ascending order). For example, if the values of x, y, and z were respectively "3", "9", and "2" then the number 14 would be displayed; but if the values were "abc", "15", and "boo" then the output would be:
Expert Answer:
Answer rating: 100% (QA)
You can achieve this by using a tryexcept block to convert the variables to integers and handle any ... View the full answer
Related Book For
An Introduction to the Mathematics of financial Derivatives
ISBN: 978-0123846822
2nd Edition
Authors: Salih N. Neftci
Posted Date:
Students also viewed these programming questions
-
The HTML program is fine I want help to figure out what's wrong with CSS that would not make my website look the same as the picture I provided. @charset "UTF-8"; /* CSS Document for CA3 */ body {...
-
I listed the codes for the following project below. The Login page loads normally; when I input the correct username and password in the Members page, it doesn't take me to "Welcome to the Members...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
- You have identified several risks on your project for which purchasing insurance is a possibility. The insurance company your firm uses has quoted reasonable rates, and your analysis shows that...
-
Explain how the investment account is affected by investee activities under the equity method.
-
The T-s diagram in Fig. 10.15 indicates an ideal refrigeration cycle operating between 120 kPa and 1200 kPa. If R134a is the refrigerant, the compression work is nearest: (a) 42 klilcg (b) 47 kJ/kg...
-
How can forward exchange contracts be used to manage foreign exchange risk?
-
Saturated steam at a gauge pressure of 2.0bar is to be used to heat a stream of ethane. The ethane enters a heat exchanger at 16?C and 1.5 bar gauge at a rate of 795m 3 /min and is heated at constant...
-
6. An annular disk of mass M, inner radius a and outer radius b is placed on a horizontal surface with coefficient of friction , as shown in the figure. At some time, an impulse Jox is applied at a...
-
Comparative balance sheets for 2021 and 2020 and a statement of income for 2021 are given below for Metagrobolize Industries. Additional information from the accounting records of Metagrobolize also...
-
Rules of professional conduct for accountants should: A) clearly spell out right from wrong in every situation. B) not be seen as strict when the client requests certain requirements. C) be...
-
When is fair market value of an asset used as the basis for an asset?
-
What residence-related matter did the Housing Assistance Tax Act of 2008 address?
-
Describe the intent of the front-loading provisions with respect to alimony payments.
-
Small Company wants to elect a tax year that follows its business cycle, which ends July 20. Is it permitted to do this?
-
If an asset is given to a charitable organization and the asset is sold, what is the effect on the charitable contribution deduction?
-
Fill the crossword puzzle. Hi there, I am having issues with this crossword puzzle. I filled out half of it, but cannot seem to figure out the rest. I flipped through textbooks, searched the...
-
Aztec Furnishings makes hand-crafted furniture for sale in its retail stores. The furniture maker has recently installed a new assembly process, including a new sander and polisher. With this new...
-
The exercises in this section prepare the reader for the next three chapters instead of dealing with the PDEs. An interested reader will find several useful problems in Betounes (1998). Let X t be a...
-
Consider the following SDE: (a) Write the above SDE in the integral form. (b) What is the value of theintegral. d(W) = 3 [W,dt +W dW]. widw, w;dw,-
-
Consider the equation below that gives interest rate dynamics in a setting where the time axis [0, T] is subdivided into it equal intervals, each of length ?: r t +? = r t + ?r t + ? t (W t+? ? W t )...
-
In Problem 102, using an interest rate of 8 percent, what single sum of money occurring at the end of year 8 is equivalent to the cash flow profile shown? Data from problem 102 Consider the following...
-
In Problem 102, with an interest rate of 6 percent, what increasing gradient series is equivalent to the cash flow profile shown if the gradient series sought has a value of X at EOY = 1 and a value...
-
Consider the following cash flow profile: With a compounded annual interest rate of 6 percent, what single sum of money at the end of the sixth year will be equivalent to the cash flow series? EOY...
Study smarter with the SolutionInn App