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
Bond [772]
4 years ago
11

Write a function that takes a string like 'one five two' and returns the corresponding integer (in this case, 152). A function j

ust like this would be used in a speech recognition system (e.g. automated phone taxi bookings) to convert a spoken number into an integer value. Here is an attempt that won't work. Your task is to replace the function body with something that works:

Computers and Technology
2 answers:
Lelu [443]4 years ago
4 0

Answer:

see explaination

Explanation:

def words2number(s):

words = s.split()

numbers = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']

result = ""

for word in words:

if word in numbers:

result += str(numbers.index(word))

return result

nikitadnepr [17]4 years ago
4 0

Answer:

Check the explanation

Explanation:

def words2number(s):

   words = s.split()

   numbers = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']

   result = ""

   for word in words:

       if word in numbers:

           result += str(numbers.index(word))

   return result

# remove below test line before submitting this code.

print(words2number('one five two'))

Kindly check the attached image below for the code output.

You might be interested in
1. Write an application that throws and catches an ArithmeticException when you attempt to take the square root of a negative va
Inessa05 [86]

Answer:

Hence the answer is given as follows,

4 0
3 years ago
What is wrong with the formula below?<br><br> SUM(A1:A5)/SUM(B1:B5)
Vlad [161]

Answer:

You forgot the "=" sign.

Explanation:

formulas in excel start with an "="

=SUM(A1:A5)/SUM(B1:B5)

4 0
4 years ago
Samuel is working on decimal and binary conversion for his college project. He is using the binary number 111011 and wants to ex
SCORPION-xisa [38]

someone help i need the answer

4 0
3 years ago
Lenders always accept applications for credit
LenKa [72]
The correct answer to the question that is being stated above is FALSE.

The statement is false because lenders do not always accept applications for credit. Lenders always consider credit history of the applicant. If the applicant has a good credit history background, then he qualifies.
3 0
4 years ago
In python 3.17 LAB: Convert to dollars
krok68 [10]

To convert the inputs to dollars and cents, we make use of a combination of multiplication and addition.

The program written in Python where comments are used to explain each line is as follows:

<em />

<em>#This gets input for the number of quarters</em>

quarters = int(input("Quarters: "))

<em>#This gets input for the number of dimes</em>

dimes = int(input("Dimes: "))

<em>#This gets input for the number of nickels</em>

nickels= int(input("Nickels: "))

<em>#This gets input for the number of pennies</em>

pennies= int(input("Pennies: "))

<em>#This converts the amount to dollars and cents</em>

dollars = quarters * 0.25 + dimes * 0.10 + nickels * 0.05 + pennies * 0.01

<em>#This prints the amount to 2 decimal places</em>

print("Amount ${:.2f}".format(dollars))

Read more about Python programs at:

brainly.com/question/22841107

7 0
3 years ago
Other questions:
  • Give two reasons why it is important to upgrade your browser when a new version becomes available.
    8·1 answer
  • Dialogue is not a characteristic of functional text because
    9·1 answer
  • Jesse earned $420 a week, and he worked 5 days a week. what is his daily wage?
    10·2 answers
  • A __________ is when the sender cryptographically marks a message with its private key, which is achieved by a cryptographic alg
    12·1 answer
  • Give an example of a situation in which shears would be the best choice and one in which scissors would suffice.
    14·1 answer
  • Ifdjgidfpojcjdizchnllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllsssssssssssssssssssssssssss
    13·2 answers
  • One of Kyle’s clients called to complain that his computer was running really slow. Kyle went to the client’s work area and star
    6·1 answer
  • Describe an example of a very poorly implemented database that you've encountered (or read about) that illustrates the potential
    12·1 answer
  • The term for an operator that may not evaluate one of its subexpressions is
    14·1 answer
  • help this poped up on my pc im on my laptop what does it mean HELP rC % M i \g e - A u t o M e r g e d - b a s e ~ 3 1 b f 3 8 5
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!