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
Write a program that computes the monthly net pay of the employee for a steel factory. The input for this program is the hourly
Mars2501 [29]

Answer:

#include<stdio.h>

int main()

{

float rate_of_pay,regular_hours,overtime_hours,grosspay,netpay,tax;

printf("Enter the Hourly rate of pay : ");

scanf("%f",&rate_of_pay);

printf("Enter the number of Regular hours : ");

scanf("%f",&regular_hours);

printf("Enter the number of Overtime hours : ");

scanf("%f",&overtime_hours);

grosspay=(regular_hours*rate_of_pay)+(1.5*overtime_hours*rate_of_pay);

netpay=grosspay-(grosspay*0.2);

printf("Employee's Gross pay = %f\n",grosspay);

printf("Tax = %f\n",0.2*grosspay);

printf("Employee's Net pay = %f\n",netpay);

return 0;

}

Note: The variables are declared as float, to support partial hours like 0.5,6.5 etc.

Explanation:

6 0
3 years ago
Write a function named enterNewPassword. This function takes no parameters. It prompts the user to enter a password until the en
zloy xaker [14]

Answer:

def enterNewPassword():

 while True:

   password = input("Enter password: ")

   has_digit = False

   for i in password:

     if i.isdigit():

       has_digit = True

       break

   

   if not has_digit or (len(password) < 8 or len(password) > 15):

     if len(password) < 8 or len(password) > 15:

       print("The password length must be between 8 and 15!")

     if not has_digit:

       print("The password must include at least one digit!")

   else:

     return password

print(enterNewPassword())

Explanation:

*The code is in Python.

Create a function named enterNewPassword that takes no parameter

Create an indefinite while loop. Inside the loop, ask the user to enter the password. Initialize the has_digit as False, this will be used to check if password contains a digit or not. Create a for loop, that that iterates through the password, if one character is digit, set the has_digit as True and stop the loop (Use isdigit() to check if the character is digit or not).

After the for loop, check if has_digit is false or the length of the password is not between 8 and 15. If the length of the password is not between 8 and 15, print the error. If has_digit is false, again print the error.

Otherwise, password met the requirements and return the password

Call the enterNewPassword() function and print the result

4 0
3 years ago
There's an App for That!
AleksandrR [38]

Answer:

Im confused man

Explanation:

6 0
3 years ago
A single instruction carried out by a computer is called a what?
pochemuha

Answer:

in computer science, an instruction is a single operation of a processor defined by the instruction set

Explanation:

if you need anymore help let me know :)

6 0
3 years ago
The computer that can be used for performing the daily life tasks that might include emailing, browsing, media sharing, entertai
ad-work [718]

Answer:

Yes, this statement is completely true

Explanation:

Yes, this statement is completely true. A personal computer is a multimedia machine and can be used to complete an incredibly large number of tasks with ease. Such tasks include all of the ones listed in the question. Aside from that other tasks depend more on the skill level and understanding of the user. For example, an individual who has a vast understanding of technology and programming can create software to perform absolutely any task they may want or need to do.

5 0
3 years ago
Other questions:
  • A drop-down menu must be contained by
    5·1 answer
  • Templates allow for the quick creation of _____.
    7·1 answer
  • Which of the following choices is not a viewing option?
    10·1 answer
  • What is NOT an issue associated with tag management systems? There is no automation available for tag management systems. Managi
    5·1 answer
  • Which formula is used to measure accuracy?
    11·1 answer
  • Wireless networks usually use ____ signals to send data.
    11·2 answers
  • Tech A states that modern vehicles use asbestos as the brake material. Tech B states that asbestos is no longer used in brakes.
    8·1 answer
  • Select all the correct answers.
    13·2 answers
  • Remember not to use tools that are ________ in any way.
    5·1 answer
  • Which item is developed last in the cyclical process?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!