1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
faust18 [17]
4 years ago
9

Three variables , x, y and z, supposedly hold strings of digits, suitable for converting to integers. Write code that converts t

hese to integers and print the sum of these three integers. However, if any variable has a value that cannot be converted to an integer, print out, 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", "2" then the number 14 would be printed; but if the values were "abc", "15", "boo" then the output would be:
bad value(s) in: x z
This is what I have so far:
try:
print(int(x)+int(y)+int(z))
except ValueError:
if x=ValueError:
print("bad value(s) in:", x)
elif y=ValueError:
print("bad value(s) in:", y)
elif z=ValueError:
print("bad value(s) in:", z)
Computers and Technology
2 answers:
faust18 [17]4 years ago
6 0

Answer:

See explaination for the program code

Explanation:

Code below:

x, y, z = "abc", "15", "boo"

errors = []

try:

x = int(x)

except ValueError:

errors.append('x')

try:

y = int(y)

except ValueError:

errors.append('y')

try:

z = int(z)

except ValueError:

errors.append('z')

if len(errors) == 0:

print(x+y+z)

else:

print('bad value(s) in: ' + ' '.join(errors))

zimovet [89]4 years ago
5 0

Answer:

Check the explanation

Explanation:

x, y, z = "abc", "15", "boo"

errors = []

try:

   x = int(x)

except ValueError:

   errors.append('x')

try:

   y = int(y)

except ValueError:

   errors.append('y')

try:

   z = int(z)

except ValueError:

   errors.append('z')

if len(errors) == 0:

   print(x+y+z)

else:

   print('bad value(s) in: ' + ' '.join(errors))

You might be interested in
What could prevent earmuffs from providing your ears good protection from noise?
uranmaximum [27]
Well for one thing, ear muffs were made to keep your ears warm, not protection from noise.
3 0
4 years ago
Which of the following is true about a hot site?
swat32

Answer:

Option(d) is the correct answer to the given question.

Explanation:

A hot site is a place off site in which the task of a corporation could restart during a massive failure.The hot site seems to have all the needed equipment for such the corporation to schedule the normal activities, such as phone jacks, replacement data, laptops, and linked devices.

  • The main objective of hot sites provide an useful backup mechanism for any corporation that wishes to pursue its business in the presence of exceptional circumstances or events.
  • All the others options are not related to hot site that's why they are incorrect option.
8 0
3 years ago
You observe scrub jays hiding food and notice that one particular individual only pretends to hide food. What kind of experiment
o-na [289]

Answer:

Theorize a group of signals that will possibly produce this type of behavior and align the signals with the behaviors.

Explanation:

6 0
3 years ago
Assume that two parallel arrays have been declared and initialized: healthOption an array of type char that contains letter code
givi [52]

Answer:

if (annualCost[0] < annualCost[1])

{

best2 = healthOption[0];

}

else

{best2 = healthOption[1];

}

Explanation:

The required code is given above.

4 0
3 years ago
Write a loop that sets each vector element to the sum of itself and the next element, except for the last element which stays th
posledela
<span>#include #include
 using namespace std;
  int main() {
   const int SCORES_SIZE = 4;
   vector bonusScores(SCORES_SIZE);
   int i = 0;
   
bonusScores.at(0) = 10; bonusScores.at(1) = 20; bonusScores.at(2) = 30; bonusScores.at(3) = 40; for (i = 0; i < SCORES_SIZE; ++i) { cout << bonusScores.at(i) << " "; } cout << endl; return 0; }</span>
8 0
3 years ago
Other questions:
  • Small programs called _______ are used to communicate with Paris Friel devices such as monitors printers portable storage device
    9·1 answer
  • Hanging out with friends, watching your favorite TV show, and buying a pair of new shoes are all examples of _____ for doing wel
    5·2 answers
  • What do you adjust to allow more or less vertical space between lines of a paragraph?
    14·1 answer
  • Which vpn protocol is a poor choice for high-performance networks with many hosts due to vulnerabilities in ms-chap?
    15·1 answer
  • A car can move, a crystal can grow, a fire alarm is sensitive and they are classified as non-living things. Explain?​
    9·1 answer
  • Who are the best candidates for members of SkillsUSA? Check all that apply. Adolph wants to be an Elementary School Teacher. Rub
    5·2 answers
  • If you were infiltrating a network (10.16.0.0/16), and searching for vulnerabilities (while trying to remain undetected), why wo
    11·2 answers
  • 69.147.76.15 is an example of what?​
    15·1 answer
  • WILL GIVE Brainliest!!!!
    9·2 answers
  • you have just received a new hdd so you connect it to your computer. the disk manager software recognizes the disk but when you
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!