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
olga nikolaevna [1]
2 years ago
10

Your task is to implement a function replace_once(t, d), that takes a text t and a replacement dictionary d, and returns the res

ult of replacing words according to the dictionary: if a word appears as a key, replace it with the dictionary value, and if a word does not appear in the dictionary, leave it alone.
Given a list of words, you can concatenate them together with spaces in between as follows:
word_list = "I love eating bananas".split()
print("Word list:", word_list)
back_together = " ".join(word_list)
print("Back together:", back_together)
# You can also join them in other ways, btw. Just DON'T do it for this homework.
print("You can also put commas:", ", ".join(word_list))
Computers and Technology
1 answer:
djverab [1.8K]2 years ago
4 0

Answer:

Explanation:

The following code is written in Python and does exactly as requested. It is a function named replace_one(t, d) that takes the two parameters one text/word and one dictionary. If the word is found as a key in the dictionary it places the value in a variable called new_word and returns it to the user, if it is not found then the function returns nothing.

def replace_once(t, d):

   if t in d:

       new_word = d.get(t)

       return new_word

   return

You might be interested in
Python Programming
Phoenix [80]

The python program that creates a Bankaccount class for a Bank ATM that is made up of the customers and has a deposit and withdrawal function is given below:

<h3>Python Code</h3>

# Python program to create Bankaccount class

# with both a deposit() and a withdraw() function

class Bank_Account:

def __init__(self):

 self.balance=0

 print("Hello!!! Welcome to the Deposit & Withdrawal Machine")

def deposit(self):

 amount=float(input("Enter amount to be Deposited: "))

 self.balance += amount

 print("\n Amount Deposited:",amount)

def withdraw(self):

 amount = float(input("Enter amount to be Withdrawn: "))

 if self.balance>=amount:

  self.balance-=amount

  print("\n You Withdrew:", amount)

 else:

  print("\n Insufficient balance ")

def display(self):

 print("\n Net Available Balance=",self.balance)

# Driver code

# creating an object of class

s = Bank_Account()

# Calling functions with that class object

deposit()

s.withdraw()

s.display()

Read more about python programming here:

brainly.com/question/26497128

#SPJ1

8 0
1 year ago
If a person communicates indirectly and attaches little value to
Mars2501 [29]

Answer: B. Low-context

5 0
2 years ago
If you were going to construct a table that only included shape names with number prefixes, which shape would you include
NikAS [45]
The answer would be A. square
3 0
3 years ago
Why do employers prefer to hire people with more work ethic?
Andrej [43]

The importance of a good work ethic in school and life. Your good work ethic tells future employers what they might expect from you on the job.

4 0
2 years ago
Database developers use the ________ to create relationships in the database.
madreJ [45]
Is it multiple choice ?<span />
7 0
3 years ago
Other questions:
  • Which of the following statements best compares and contrasts the role of story writers and script writers
    12·1 answer
  • ON QUIZ PLEASE HELP
    13·1 answer
  • What is the difference between digital art and digital design?
    8·1 answer
  • What is the term for an understanding about the processes that underlie memory, which emerges and improves during middle childho
    7·2 answers
  • Having friends who cause you stress can decrease your happiness, which can in turn
    13·2 answers
  • Converting Denary to Binary
    15·1 answer
  • Which cable standard is a standard for newer digital cable, satellite, and cable modem connections?
    11·1 answer
  • Creating Classes
    10·1 answer
  • Multiple choice:
    12·2 answers
  • How do you stop getting emails from brainly saying "sarah from brainly has answered your question"
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!