#Python: The given program reads a list of single-word first names and ages (ending with -1), and outputs that list with the age incremented. The program fails and throws an exception if the second input on a line is a string rather than an integer. At FIXME in the code, add try and except blocks to catch the ValueError exception and output 0 for the age.

Ex: If the input is:

Lee 18
Lua 21
Mary Beth 19
Stu 33
-1
then the output is:

Lee 19
Lua 22
Mary 0
Stu 34

"# Split input into 2 parts: name and age
parts = input().split()
name = parts[0]
while name != '-1':
# FIXME: The following line will throw ValueError exception.
# Insert try/except blocks to catch the exception.
age = int(parts[1]) + 1
print('{} {}'.format(name, age))

# Get next line
parts = input().split()
name = parts[0]"

Answers

Answer 1

The program illustrates the use of catching exceptions.

What are exceptions?

Exceptions are program statements that are used to control program errors, and prevent a program from crashing.

How to fix write the exception

The statements that catch the exception in the program are:

try:

       age = int(parts[1]) + 1

       print('{} {}'.format(name, age))

       # Get next line

       parts = input().split()

       name = parts[0]

   except ValueError:

       print('Invalid value!')

       # Get next line

       parts = input().split()

       name = parts[0]

The complete program

The complete program is as follows:

# Split input into 2 parts: name and age

parts = input().split()

name = parts[0]

while name != '-1':

   # FIXME: The following line will throw ValueError exception.

   # Insert try/except blocks to catch the exception.

   try:

       age = int(parts[1]) + 1

       print('{} {}'.format(name, age))

       # Get next line

       parts = input().split()

       name = parts[0]

   except ValueError:

       print('Invalid value!')

       # Get next line

       parts = input().split()

       name = parts[0]

Read more about program exceptions at:

https://brainly.com/question/25012091


Related Questions

Identify science and technology policies that could be adapted or implemented in the Philippines?​

Answers

Answer:

In the Philippines, universities dominate the research arena. So you have scientists who make research for the sake of research.

The private sector may or may not adopt the research. If a research in UP finds a molecule that may kill cancer, we are not sure whether that research will be adopted or not.

We are not sure if that research will be continued to actual creation of a medicine of cancer. This is because our scientists are working in universities and not in actual pharma companies.

In other countries, the scientists build their own companies. So their research go from drug development to actual manufacturing and marketing of medicines.

So when they start a research, you know that in the next 5 to 10 years, these scientists will produce drugs which the public can benefit from.

This is why the Philippine research is not thriving as it should. Our government should support our start ups.

When scientists are given grants for research, they should also be given grants to start their company. Unfortunately, start up grant is not a function of the DOST. It is of the DTI.    

Explanation:

In the Philippines, universities dominate the research arena. So you have scientists who make research for the sake of research.

Which sector does not adopt research?

The private sector may or may not adopt the research. If a research in UP finds a molecule that may kill cancer, we are not sure whether that research will be adopted or not.

We are not sure if that research will be continued to actual creation of a medicine of cancer. This is because our scientists are working in universities and not in actual pharma companies.

In other countries, the scientists build their own companies. So their research go from drug development to actual manufacturing and marketing of medicines. So when they start a research, you know that in the next 5 to 10 years, these scientists will produce drugs which the public can benefit from.

This is why the Philippine research is not thriving as it should. Our government should support our start ups. When scientists are given grants for research, they should also be given grants to start their company. Unfortunately, start up grant is not a function of the dust. It is of the DTI.  

Therefore, In the Philippines, universities dominate the research arena. So you have scientists who make research for the sake of research.

Learn more about Philippine on:

https://brainly.com/question/26599508

#SPJ2

 

The diagram shows the positions of the Sun, Earth, and Moon during each moon phase. When viewed from Earth, at what point does the Moon appear darkest?

Answers

Answer:

B

Explanation:

when it is on the same side of Earth as the Sun because it appears all black because of the shadow

How do i open screenshots on school chromebook?

Answers

Answer:

you have to open your file explorer and open the screenshot folder.

Explanation:

Answer:

1. Go to the small magnifying glass on the bottom of the taskbar.

2. Then type in "Snipping Tool" in the search bar.

3. Then click on "Open" or the App.

4. Then a small window should pop up and click "Try Snip & Sketch"

5. Then press the "New" button.

6. The screen should go slightly darker and you can drag your mouse to whatever image or screenshot you want to take. As long as it's on the desktop screen, it shall capture all of it.

7. After capturing the image you can edit it with the tools provided.

8. After finishing on the steps, you can either press either "Save As" or "Copy".

Instead of being so troublesome, you can always pin the app to taskbar or press "Window Logo Key + Shift + S". There should be a notification after finished.  

After save as you can go look at your files afterwards.  

Python problem: The program needs to output the numbers 1 to 9, each on a separate line, followed by a dot:

Answers

Answer:

for i in range(1,10): print("{}.".format(i))

Explanation:

here's a one liner that does what you need.

A game is played by moving a game piece left or right along a horizontal game board. The board consists of spaces of various colors, as shown. The circle represents the initial location of the game piece.

Yellow Black Green Green Red Yellow Black Black Yellow Black

The following algorithm indicates how the game is played. The game continues until the game is either won by landing on the red space or lost when the piece moves off either end of the board.

Step 1: Place a game piece on a space that is not red and set a counter to 0.
Step 2: If the game piece is on a yellow space, move the game piece 3 positions to the left and go to step 3. Otherwise, if the game piece is on a black space, move the game piece 1 position to the left and go to step 3. Otherwise, if the game piece is on a green space, move the game piece 2 positions to the right and go to step 3.
Step 3: Increase the value of the counter by 1.
Step 4: If game piece is on the red space or moved off the end of the game board, the game is complete. Otherwise, go back to step 2. If a game is begun by placing the game piece on the rightmost black space for step 1, what will be the value of the counter at the end of the game

Required:
If game piece is on the red space or moved off the end of the game board, the game is complete. Otherwise, go back to step 2. If a game is begun by placing the game piece on the rightmost black space for step 1, what will be the value of the counter at the end of the game?

Answers

The value of the counter of the given algorithm at the end of the game is; 4

How to solve Algorithms?

From the attached table, we see the algorithm of the given game.

Now, the black circle is initially under the column black.

From the given conditions, step 1 says since the space is not red we should set a counter to 0. Thus, the counter will be set to 0.

Since the game piece is under the black column, according to step 2, we will move the game piece 1 position to the left and go to step 3.

By moving one position to the left, the game piece will be under the yellow column. We now increase the counter by 1 to 1.

According to step 2, at yellow, we move the game piece 3 places to the left and it will land on yellow and we increase the counter to 2 and move 3 places to the left again to stop at green.

At green we increase the counter to 3 and then move two spaces to the left which is the left end of the board and we will increase the counter to 4 and the game will be complete according to step 4.

Read more about Solving Algorithms at; https://brainly.com/question/24793921

Info, and Contact Us. She will create a hierarchy of page elements and revise the style sheets. In this case, the Home page contains two _____ elements.

Answers

Answer:

link

Explanation:

WHY can C only approximate most (mathematical) real numbers?

Answers

Answer:

WHY can C only approximate most (mathematical) real numbers?

In a computer, a real value is stored in a finite number of bits (typically 32 or 64 bits). So a computer's representation of real numbers can only approximate most mathematical real numbers. This is because only finitely many different values can be stored in a finite number of bits.

Explanation:

I hope it will help you....

[tex]kai6417[/tex]

#carryonleraning

what is the longest word that you can write using the letters only on one row of the keyboard of your computer?

Answers

Answer:

TYPEWRITER is the longest word that you can write using the letters only on one row of your computer's keyboard.

Explanation:

hope this helps

Question 1 of 10
What are mobile collaborative tools most often used for?
A. Creating different types of text documents, spreadsheets, and
presentations

B. Writing out the steps to solve a problem

C. Meeting and sharing securely on a top-secret program

D. Moving about and working together on inventory management

Answers

Answer:

I belive it is A but i could be wrong

Explanation:

Answer:

The answer is D.

Explanation:

Fill the range c15:e15 with the formula in cell b15 to determine the average revenue per salesperson in quarters 2 and 3 and year to date

Answers

Excel formulas are expressions used to perform computation.

The Excel formula to enter in range C15:E15 are: = (C14/G2) ,= (D14/G2) and = (E14/G2)

How to determine the Excel formula

From the complete question, the formula in cell B15 is:

= (B14/G2)

When the formula is moved to fill the range C15 to E15, we change B14 to C14, D14 and E14.

So, we have:

C15= (C14/G2)

D15= (D14/G2)

E15= (E14/G2)

Hence, the formulas in range C15:E15 are:

= (C14/G2) ,= (D14/G2) and = (E14/G2)

Read more about Excel formulas at:

https://brainly.com/question/14820723

What does it mean when we say that Unity “handles terrain natively,” and how can that assist in game development?

Answers

Answer:

yes it is true

Explanation:

happy fun

What does the x mean in .docx

Answers

Answer:

When Microsoft switched to XML-based file formats in Office 2007, they added the 'x' to the file extensions to differentiate from the previous, incompatible formats such as dox to docx.

In other words. X is extended.

A small office providing television services in Chicago has contacted Mark, a network administrator, to set up a network connection for their operations. The total strength of devices will not exceed 10, and so Mark decides that a LAN connection is all that is required for their functionality. Mark, however, wants to ensure that the devices are connected centrally, and for this purpose he plans on installing a central switch. Analyze which physical topology is best suited for this purpose.

Answers

The physical topology which is best suited for this network connection is a star topology.

What is a topology?

A topology can be defined as the graphical representation of the various networking devices that are used to create and manage a network connection.

The types of topology.

In Computer networking, there are six main types of topology and these include the following:

Bus topologyTree topologyHybrid topologyRing topologyMesh topologyStar topology

A star topology refers to a type of topology in which each networking device is physically connected to a central node such as a hub, router, or switch, which are typically acting as connecting nodes.

Read more on topology here: https://brainly.com/question/17036446

A software repository, also known as a 'repo', is:

Answers

Answer:

A software repository, or “repo” for short, is a storage location for software packages.

Excel 365 is primarily used to produce Word documents.

Answers

If this is a true and false question it would be False

Excel 365 is primarily used to produce Word documents is a false statement.

What is Microsoft Word and Excel meant for?

Microsoft Word is known to be a kind of word processing software that is often used for writing letters, memos, reports and others.

The Microsoft Excel is known to be a spreadsheet software that is meant to be used for calculations, creating charts and recording data about any  business processes.

Conclusively, Excel 365 is primarily used to produce calculations and not word document.

Learn more about Excel from

https://brainly.com/question/25879801

Computer always produces wrong output true or false

Answers

Answer: You really need a screenshot here. That's it

Explanation: I can't give a definitive answer without a screenshot, lol

The Internet emerged as a new medium for visualization and brought all the following EXCEPT Group of answer choices new forms of computation of business logic. worldwide digital distribution of visualization. new graphics displays through PC displays. immersive environments for consuming data.

Answers

The Internet emerged as a new medium for visualization and brought all the following EXCEPT : Computation of business logic.

What is business logic?

Business Logic refers to a series of algorithms that are the basis of different business software. The aim of business logic is the implementation of higher-level algorithms to process data hence generate precise output.

The Internet did not bring business logic to the surface but the implementation of Information Technology (IT) to business.

Hence, the Internet emerged as a new medium for visualization and brought all the following except computation of business logic.

Learn more internet here : https://brainly.com/question/97026

Help your professor to calculate the exam average and the number of students passing the course by writing a maria program. The program will take as input the number of exam papers and the exam points for each student. At the and show the class average and the number of students passing the course. Note that the passing grade is 60.

Answers

#include <iostream>

using namespace std;

int main ()

{

int num =0 ;

int points=0 ;

int pointss=0;

int term =0;

int passes =0;

cout<<"type number of "<<endl;

cin>> num;

for(int i =0;i<num;i++)

{

cout<<"type points "<<endl;

cin>>points;

pointss=points + pointss;

if(points>=60)

{

passes++;

}

}

cout<<"that are points: "<<endl;

cout<<pointss<<endl;

cout<<"that is num: "<<endl;

cout<<num<<endl;

cout<<"average: "<<endl;

cout<<pointss/num<<endl;

cout<<"Number of students who pass: "<<endl;

cout<<passes<<endl;

return 0;

}

Question 1
Which of the following is a software threat?
a
O A) session hijacking
OB) overflow attack
OC) cross-site scripting (XSS)
OD) hacking

Answers

well we can rule out session as this is a threat to the computer not the software

next let's talk about overflow attack as this can be used on any software that has connecten to the internet

cross site scripting is for websites only as it involves loading code on to a website

and hacking if a very broad term so I would rule that out also

so I believe the answer is b

hope I helped

scav

The one that is software threat is an overflow attack. The correct option is b.

What is a software threat?

Software threats are harmful programs and pieces of code that can harm your computer and steal your personal or financial data. Because of this, these harmful programs are frequently referred to as malware (short for "malicious software").

Nowadays, many software vulnerabilities explicitly target smartphones, making cybersecurity strategies based on desktop PCs ineffective in some cases.

Apps, and smartphone viruses, are merely mobile versions of viruses that target your desktop or laptop computer. Blue jacking is the practice of sending unwanted or unsolicited Bluetooth messages to complete strangers.

Therefore, the correct option is b, overflow attack.

To learn more about software threats, refer to the below link:

https://brainly.com/question/28048202

#SPJ2

2 What is the different between mouse and trackbeel?​

Answers

Answer:

Trackball and Mouse is that trackball is a stationary pointing device with a ball on its top or side. While mouse is a pointing device that fits comfortably under the palm of your hand. With a mouse, users control the movement of the pointer.

Explanation:

I hope this helps!

Answer:

mouse moves by using a sensor to see how far the mouse has moved in real time and give the input to the computer. and a trackball uses sensors to see how far the ball has moved and give the input to the computer

Explanation:

In the context of the data administration component of a database management system (DBMS), the acronym CRUD stands for _____. Group of answer choices create, read, update, and delete copy, revise, undo, and define create, repeat, undo, and develop copy, read, update, and define

Answers

Answer:

C.R.U.D stands for Create, Read, Update, Delete.

Explanation:

1. (A) What do you mean by computer? Discuss the use of
computer in daily life.

Answers

Answer:

A computer is an electronic device that manipulates information or data.

We use computers in schools and colleges all around the world.

Computer technologies are important to teach students digitally and creatively with data visualization. In a classroom, students used computers to explore their creativity and imagination.

Answer:

an electronic device for storing and processing data, typically in binary form, according to instructions given to it in a variable program.

Some people use a computer to take online classes.Computers have many other uses at home like financial calculations also. You can also access banking and business services from home via the internet with the help of a computer.

examples of a computer organizing itself

Answers

I don’t think if there is one that can do that only softwares

Write the program of while loop .

Answers

Answer:#include<stdio.h>  

int main(){    

int i=1;      

while(i<=10){      

printf("%d \n",i);      

i++;      

}  

return 0;  

}    

Explanation:

This is the program I coded on the while loop.

In this exercise we have to use the knowledge of programming in C code  to describe a looping so we have the code.

The code can be found in the attached image.

How to repeat code in C?

Repeat commands are a feature that allows a certain piece of code in a program to be repeated a certain number of times. In C there are three repetition commands: while, do-while and for.

So in a simpler way the code is:

#include<stdio.h>  

int main(){    

int i=1;  

while(i<=10){    

printf("%d \n",i);    

i++;    

}  

return 0;  

}    

See more about C code at brainly.com/question/25870717

What module do you need to import in order to use a pseudo-random number in your game?

A. randomizer
B. guess
C. guesser
D. random

Answers

D: Random I don’t think the others are even valid python Libs

By using the radiant method from the random module and need to import in order to use a pseudo-random number in your game.

What is randint method?

The randint() method is a method or function in the random python module. It is used to get or return an integer number within a specified range.

To use the method, the module must be imported into the python file with the "import random" statement, then the method is referenced using dot notation and specifying the range of integer numbers. Syntax: random. randint first_number, last_number note that the last number in the range is inclusive in the selection.

Random numbers refers to a set of unbiased numbers formed within a defined set of interval. Random number generation using programming paradigm are done using the random module and not the math module.

Therefore, By using the radiant method from the random module and need to import in order to use a pseudo-random number in your game.

Learn more about radiant method on:

https://brainly.com/question/29102331

#SPJ2

4. What organization is responsible for publishing Request for Comments (RFC)?

Answers

Answer:

IETF

Explanation:

The Internet Engineering Task Force.

What is the controller in this image know as? Choose one

Answers

Answer:

mode dial

Explanation:

Which of formula contains an absolute cell reference?
=A1!+(A4*2%)
=SUM($B$7:$B$9)
=4000+2/(3*24)
=COUNT(A3:A7, B3:B12)

Answers

Which formula contains an absolute cell reference? =SUM($B$7:$B$9)

In Task 2, you worked with Sleuth Kit and Autopsy which rely on the Linux Web service called __________.

Answers

Answer: Apache

Explanation:

You restarted Apache system in the cmd in the kali linux vm.

We call any device connected to the Internet a(n) ________. Group of answer choices router host IP client

Answers

Answer:

ADSL modem

Explanation:

Other Questions
I need help with this exercise! How does prokaryotic dna differ from eukaryotic dna?. If you were looking to take a historical vacation to the Byzantine Empire's most important architectural achievement, you would most likely visit A flashlight bulb is connected to a dry cell of voltage 2. 25 v. It draws 35. 0 ma (1000 ma = 1 a). What is its resistance?. You hold a softball in the palm of your hand and toss it up. Draw the diagrams while the ball is still touching your hands.Please. help me with this question. I really need help please Why is it appropriate that Simons hair is black, symbolically? Why could it be appropriate for it to be blonde? Here are scores for two softball teams for seven innings. Each team's total score is the sum of the numbers in its row. Rosie's Riveters beat The Susan Bees by how many runs? An equation of the circle with center (h, k) and radius r is ()^2+()^2=^2 A birch tree that is 4 ft tall grows at a rate of 1 ft per year. A larch tree that is 6 ft tall grows at a rate of 0.5 ft per year.Let the variable t represent time in years and let the variable h represent height in feet.In how many years will the trees be the same height?Which system of equations can be used to solve this problem?{h=1+4th=0.5+6t{h=4+th=6+0.5t{h=5th=6.5t{h=4th=60.5t Nast also played a huge role in associating Democrats with the donkey. The donkey symbol actually dates back to before Nast's time. During the election of 1828, Andrew Jackson's critics tried to mock him by comparing him to a foolish donkey.Which phrase from the passage helps you understand the meaning of the word associating?A. dates back to beforeB. by comparing him toC. played a huge roleD. tried to mock him A forest full of the many kinds of trees and grasses is an example of a. Which system of equations has exactly one solution? O 2x - 4y = 8 X+y = 7 3x+y=-1 6x+2y = -2 3x + 3y = 3 -6x-6y=3 3x-2y = 4 -3x+2y = 4 When an economy is operating inside its production possibilities frontier we know that :_________a. the economy is operating with efficiency. b. to produced more of one good, the economy would have to give up some of the other good. c. moving to a point on its production possibilities frontier would be economic growth. d. there are unused resources or inefficiencies in the economy. cual es la masa de los planetas, y la distancia que hay de la tierra a cada uno de ellos.Ayuda pliss trait shows only if both parents pass it oncodominanrecessivedominant What is the final step in the decision-making process(1 Point)make a decisionevaluate your choicesplan how to reach your goalanalyze your resources Andrs is writing an article for his towns parks and recreation website about the different types of rowing boats. The following excerpt is from the opening of his article.Using nautical terms helps others understand and collaborate on board your boat. When facing toward the bow, or the front of the boat, your left side is called portside and the right is called starboard. Many rowboats feature a square stern, or rear of the boat, toward which the rower faces while propelling the boat forward with oars.How would you explain Andrss strategy for organizing his ideas? A. Andrs defines unfamiliar terms for the reader using the definition of organizational strategy. B. Andrs contrasts the parts of the boat using the comparison and contrast organizational strategy. C. Andrs explains the importance of understanding boat terminology using the cause-and-effect organizational strategy. D. Andrs classifies his ideas about rowing according to different nautical concepts using the classification organizational strategy. The atomic weight of an atom is the sum of the mass of the particles in the nucleus of the atom. These particles are called?a) electrons and neutrons b) electrons and protons c) neutrons and protons d) electrons, protons, and neutrons answer both questions and get 20 points and brainliest