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
sladkih [1.3K]
4 years ago
7

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

ese 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
Computers and Technology
1 answer:
sineoko [7]4 years ago
5 0

Answer:

Required code is given below:

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
Question 4. Use simulate_several_key_strikes 1000 times, each time simulating the monkey striking 11 keys. Compute the proportio
Arisa [49]

Answer:

Chech the explanation

Explanation:

<em>In [16]:</em>

<em />

# Your answer to this question might be written on more than a line.

datascience_trials = make_array()

for  i  in np.arange(1000):

            datascience_trials = np.append(datascience_trials, simulate_several_key_strikes(1))

datascience_proportion = np.count_nonzero(datascience_trials == 'datascience')/1000

datascience_proportion

<em>Out [16]:</em>

0.0

<em>In [17]:</em>

_ = ok.grade('q2_4')

````````````````````````````````````````````````````````````````````````````````````````````````````````

#Running tests

4 0
3 years ago
Katie is training for a marathon and wants to run a
Eva8 [605]

Answer: 115 miles a month

Explanation:

460/4

which equals

<em><u>115 miles per month</u></em>

6 0
3 years ago
Anybody want to help me figure out how to put this on a resumè
Svet_ta [14]

Answer:

OMG IM LIKE BLUSHING AS DARK AS A TOMATO RIGHT NOW

5 0
3 years ago
What is Discord Packing????
maria [59]

Answer:

my discord is outback_streakhouse#7277

6 0
3 years ago
If you insert a picture, resize and reposition it, and then change to a different picture, you must modify the new picture to
Mashcka [7]

Answer:

false , that is not true

Explanation:

because a person can change to a different picture , but it Is not by force it will have a match to the original

3 0
2 years ago
Read 2 more answers
Other questions:
  • Sorts by value in reverse order; keeps the same key
    6·1 answer
  • A(n) _______ created in Microsoft Word or another word-processing program works well as a shell for a PowerPoint presentation.a.
    9·1 answer
  • . Network navigation devices, such as routers, help datatravel in bundles that are referred toas………..
    14·1 answer
  • It chapter 2 pennywise
    13·1 answer
  • When is it not necessary to invoke the method myMethod using dot notation? When myMethod is private. When myMethod is invoked by
    14·2 answers
  • "in troubleshooting a boot problem, what is the advantage of restoring all uefi/bios settings to their default values?"
    13·1 answer
  • Write a calculator program that will allow only addition, subtraction, multiplication &amp; division. Have the
    7·1 answer
  • What does the National Institute of Standards and Technology do? Promotes innovation by advancing measurement standards promotes
    15·2 answers
  • In 1980, IBM's cheapest computer was more affordable than Apple's.<br><br><br> True<br><br> False
    10·1 answer
  • A small square at the right corner of the table is what?​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!