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
A hacker has successfully infected an internet-facing server which he will then use to send junk mail, take part in coordinated
julia-pushkina [17]
Botnet Trojan. Hopefully that’s helpful :)
5 0
3 years ago
The rules of a programming language constitute its__________________
kogti [31]
The rules of a programming language constitute its syntax.
7 0
2 years ago
Is the core of an operating system that controls its basic functions.
WINSTONCH [101]

Answer:

Explanation:

Tweaker

5 0
4 years ago
A computer that is not connected to a network is called a........​
Lesechka [4]

Answer:

standalone computer

Explanation:

If your PC is not connected to a network, it is referred to as a standalone computer.

Hope this helped and have a good day

5 0
2 years ago
Read 2 more answers
In attempts to improve their contribution to the environment, a company decided to adapt to green computing. Which of these tech
timama [110]

Answer:

All of them apply

Explanation:

Green computing is the process of using environmental friendly computers and its associated components, accessories and other supporting devices.

Virtualization helps us to reduce the number of hardware that we are using.

Grid computers helps us to reduce the use of number of machines and thus supporting the environment in a right way.

Recycling process. Any material that we use needs to be recycled effectively and also in an environmental friendly way.

Autonomic computing uses eco-friendly system which in turn hugely support green computing.

8 0
3 years ago
Other questions:
  • Which of the following is an important initial step in designing an interface
    7·1 answer
  • Helllllp: Virtual private networks require a secure remote connection.<br> True or False?
    10·2 answers
  • IF YOU KNOW THE ANSWER TO THIS PLEASE ANSWER ASAP
    12·1 answer
  • Which speaker port should you use when connecting a single speaker to a pc?
    6·1 answer
  • Write a Java program that prompts the user to enter integer values for the sides of a triangle and then displays the values and
    7·1 answer
  • What kind of negative social impact has wireless communications had on today's society?
    6·2 answers
  • How does it transform your ways of socializing
    11·1 answer
  • Mô tả những lợi ích của việc sử dụng đa xử lý không đồng nhất trong một hệ thống di động
    8·1 answer
  • I need the answer ASAP. I’ll mark brainliest if right
    5·1 answer
  • How is binary used in pixels and in sound?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!