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
IgorC [24]
3 years ago
11

Exercise 9.2.9: Strings To Integers5 points

Computers and Technology
1 answer:
netineya [11]3 years ago
5 0

Answer:

x=input("Enter a String")

def safe_int(x):

   #lis1=[ int(x)if x.isdigit() else 0 for x in list_of_strings]

   lis1=[]

   lis1=x.split()

   print(lis1)

   flag=0

   j=0

   while(j in range(len(lis1))):

       if(lis1[j].isdigit()):

           flag==0

       else:

           flag==1

           try:

               if(int(lis1[j])):

                   lis1[j]=int(lis[j])

               else:

                   flag==1

                   break

           except:

               print("Cannot convert to integer")

       j+=1

   print(lis1)    

   

   

safe_int(x)

Explanation:

We are taking as an input a sentence, and then splitting it into various list items, and storing them in a list. Now we try to convert each item to integer and using try-except print the message cannot convert if its not possible or else converts it. As a check. enter 0 2 7 0   and also try Hello World.

You might be interested in
Which of the following is considered a benefit when using slab allocator?
tatyana61 [14]

Answer:

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

Explanation:

The main advantage of slab allocator is that There is no memory is lost because of the fragmentation this is due to some driver data framework has a cache memory that is connected to it.

  • In the slab allocator the resources are repeatedly assigned or free to handle them. It is a type of memory management scheme that is used for distributing resources to the memory.
  • All the other options are not considered as advantages of Slab allocator that's why they are an incorrect options.
7 0
3 years ago
Write a class named Car that has the following fields: yearMode1. The yearModel field is an int that holds the car's year model.
Gekata [30.6K]
Skeh wkf ahfmroztdjdy
Dmgk
Ann Write a class named Car that has the following fields: yearMode1. The yearModel field is an int that holds the car's year model. make. The make field is a String object that holds the make of the car, such as "Ford" "Chevrolet", "Honda", etc. speed. The speed field is an int that holds the car's current speed. In addition, the class should have the following methods . Constructor. The constructor should accept the car's year model and make as ments. These values should be assigned to the object's yearModel and make fields. The constructor should also assign 0 to the speed field. Accessor. The appropriate accessor methods get the values stored in an object's yearModel, make, and speed fields. , accelerate. The accelerate method should add 5 to the speed field each time it is called _________. brake. The brake method should subtract 5 from the speed field each time it is called.
8 0
3 years ago
Read 2 more answers
What is the best anime that you like the most (give me 3 plz)
Dmitry [639]

Answer:

The rising of shied hero, last hope, and dragon pilot.

4 0
3 years ago
Read 2 more answers
Put these events in the order in which they occurred,
lakkis [162]

Answer:

  1. Local fisherman recover the body of Major Martin off the coast  of Spain .
  2. Spanish officials pass off the information in the briefcase to  German agents.
  3. Major Martin's name appears on a casualty list in a British  newspaper.
  4. Germany prepares for an imminent attack on the island of  Sardinia.

Explanation:

This above is the order in which Operation Mincemeat was executed in WW2 to deceive the Germans into believing that the Allies were going to invade the Balkans directly instead of Sicily which was their actual target.

The plan involved a fictitious Major Martin who had secret documents about the Allied invasion of the Balkans. After the body was released from a British submarine, it washed up in Spain where it was found by local fishermen.

Spanish officials then passed the information in the briefcase Major Martin had to German intelligence. To further reinforce the ruse, the British published Major Martin's name in a casualty list.

The Germans were thoroughly convinced and switched forces from Sicily for the defence of the Balkans and the island of Sicily.

5 0
3 years ago
Precautionary measures to be observed when using ICT tools​
Dafna11 [192]

Answer:

ICT is the abbreviated form of Information and Communication. It included different technologies like mobile phones, computers, USBs etc.

Following are two precautionary measures which should be observed when using any kind of ICT:

  1. Use of Antivirus: It can used to protect anything placed inside the technology especially from hacking and viruses which can create many issues.
  2. Backup Data: Creating a backup of the data stored in the device is important as it can be recalled when the device malfunctions. Backup of the data can be created through using USBs, CDs etc or through cloud storage
7 0
3 years ago
Other questions:
  • Which area of the network would a college it staff most likely have to redesign as a direct result of many students bringing the
    10·1 answer
  • A compound document contains _______ from different applications.
    12·2 answers
  • Double clicking a word selects the entire word?
    10·1 answer
  • PLEASE HELP
    6·1 answer
  • Strobe lights can become more yellow as they age true or false
    8·1 answer
  • Which of the following is not a key way that a LAN shares
    15·1 answer
  • relational integrity constraints are rules that enforce basic and fundamental information-based constraints. True or False
    9·1 answer
  • Which of the following is NOT a valid name for a function?
    5·1 answer
  • Does anyone know how to fix this???
    11·1 answer
  • I have a problem with my Nintendo DS lite does anyone know how to fix it?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!