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]
3 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]3 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
Mr. Yang is a doctor who regards video games as an effective means of staying fit. What type of game would he recommend to his p
morpeh [17]

Answer:

D. An exergame

Explanation:

It is because the exercise game is the suitable game to staying fit. For example wii video game able to give the similar experience to outdoor activities such as playing tennis, kick boxing etc.

8 0
3 years ago
Read 2 more answers
SUB2 WWolfPlays on yt <br><br><br> true or false if false ima cri
VMariaS [17]

Answer:

True

Explanation:

Plz brainlist

5 0
2 years ago
Read 2 more answers
What type of malicious software tries to gather information about you without your consent?
AlekseyPX

Answer:

B-malware

Explanation:

I do tech and i help work on computars.

6 0
3 years ago
Write your own printArray() function found in Processing for the Arduino. For simplicity, you can limit printArray() to integer
VLD [36.1K]

Answer:

Follows are the method definition to this question:

void printArray(int arrayToPrint[], int arraySize) //defining a method printArray that accepts two array in its parameters

{

for (int j = 0; j < arraySize; j++)//defining for loop print Serial numbers

{

Serial.print("[");//use print method to print square bracket

Serial.print(j);//use print method to print Serial numbers

Serial.print("]: ");//use print method to print square bracket

Serial.println(arrayToPrint[j]);//printing array value

}

}

Explanation:

In the above code, a method "printArray" is declared that holds two arrays "arrayToPrint and arraySize" as a parameter, and inside the method is used for loop to print the values.

In the loop, first, it uses the square bracket to print the serial number and in the last step, it prints array values.

6 0
2 years ago
Consider two different implementations of the same instruction set architecture (ISA). The instructions can be divided into four
PSYCHO15rus [73]

Answer: Find answers in the attachments

Explanation:

3 0
3 years ago
Other questions:
  • How has technology influenced space exploration?
    13·1 answer
  • An app where you spin a wheel for coins and exchange for giftcards
    6·1 answer
  • To prevent unauthorized access and use, at a minimum a company should have a written __________ that outlines the activities for
    6·1 answer
  • How would you define a relational database ?
    12·1 answer
  • The domain name service (dns is a distributed database that allows users to communicate with each other computers by:
    7·1 answer
  • Which of the following are characteristics of algorithms? Choose all that apply. They take a step-by-step approach to performing
    12·1 answer
  • Which of the following refers to a collection of colors, fonts, and effects that can be
    6·1 answer
  • My friend has a battery of 9000mah and loses 10 every day how many days well it take to go to zero
    13·1 answer
  • What is a command-line program?
    8·2 answers
  • What is computer topology​
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!