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
Zanzabum
2 years ago
5

The y and z keys swapping position is messing with your touch typing. You decide to write out your email as if the keys were in

the correct position and then use Python to swap all ys and zs. Your task here is to write a function called fix_yz. This function takes a single argument which will be a string. Your function needs to return this string with all of the ys and zs swapped, and all of the Ys and Zs swapped. Here are some example calls to your function:
s = fix_yz('What did zou saz?')print(s)What did you say?s = fix_yz('Zour tip about the yoo was a great one!')print(s)Your tip about the zoo was a great one!s = fix_yz('We onlz have one week left')print(s)We only have one week left :(HintThe auto-marker is expecting you to submit only your fix_yz function definition. You should not include any calls to your function.

Engineering
1 answer:
Zarrin [17]2 years ago
4 0

Answer:

# the function fix_yz is defined

# it takes a string as parameter

def fix_yz(word):

   # new_word is to hold the new corrected string

   new_word = ""

   # loop through the string

   # and check for any instance of y or z.

   # if any instance is found, it is replaced accordingly

   for each_letter in word:

       if each_letter == 'z':

           new_word += 'y'

       elif each_letter == 'Z':

           new_word += 'Y'    

       elif each_letter == 'y':

           new_word += 'z'

       elif each_letter == 'Y':

           new_word += 'Z'        

       else:

           new_word += each_letter

   # the value of new string is returned

   return new_word        

Explanation:

The function is written in Python 3 and it is well commented. An image is attached showing the output of the given example.

The function take a string as input. It then loop through the string and check for any instance of 'y' or 'z'; if any instance is found it is swapped accordingly and then append to the new_word.

The value of bew_word is returned after the loop.

You might be interested in
Q.17) A 50-acre catchment containing cropland is converted ot a Qatar mail
Ghella [55]

Answer:

Option D

Explanation:

A post development hydrograph will have lower concentration time and lower infiltration losses and hence sooner peak and higher peak and more runoff or higher area under graph. Therefore, all the answers are correct hence option D

3 0
2 years ago
Easy POINTS computer genius help me plz
Norma-Jean [14]

Answer:

dedededededede

Explanation:

4 0
3 years ago
C++ - Green Crud Fibonacci programThe following program is to be written with a loop. You are to write this program three times
Fynjy0 [20]

Answer:

Below is the required code:

Explanation:

Using for loop

#include <iostream>

using namespace std;

int main()

{

    //Initial crud size

    int init = 0;

    int newCrud;

    int next=0;

    //Number of days to simulate

    int no_days;

    int day;

    cout << "Enter initial amount of green crud: ";

    cin >> newCrud;

    cout << "Enter number of days to simulate: ";

    cin >> no_days;

    for (day = 10; day<=no_days; day++)

    {

         if (day % 10 == 0)

         {

             next = newCrud + init;

         }

             newCrud = init;

             init = next;

    }

    if (no_days < 5)

    cout << "\nCrud reproduce only after 5 days minimum.Hence the current amount is "

    << newCrud << " pounds.";

    else

    cout << "On day " << no_days << " you have " << init

    << " pounds of green crud." << endl;

    cout << "\nWould you like to continue? (y or n): ";

    cin >> ans;

         return 0;

}

Output:

         Enter initial amount of green crud: 5

         Enter number of days to simulate: 220

    On day 220 you have 10485760 pounds of green crud.

Using while loop

Program:

#include <iostream>

using namespace std;

int main()

{

    char ans='y';

    while (ans == 'Y' || ans == 'y')

    {

         //Initial crud size

         int init = 0;

         int newCrud;

         int next=0;

         //Number of days to simulate

         int no_days;

         int day;

         cout << "Enter initial amount of green crud:

         ";

         cin >> newCrud;

         cout << "Enter number of days to simulate:

         ";

         cin >> no_days;

         for (day = 10; day<=no_days; day++)

         {

             if (day % 10 == 0)

             {

                  next = newCrud + init;

             }

                  newCrud = init;

                  init = next;

         }

         if (no_days < 5)

         cout << "\nCrud reproduce only after 5 days

         minimum.Hence the current amount is "

         << newCrud << " pounds.";

         else

         cout << "On day " << no_days << " you have "

         << init

         << " pounds of green crud." << endl;

         cout << "\nWould you like to continue? (y or

         n): ";

         cin >> ans;

    }

    return 0;

}

Output:

Enter initial amount of green crud: 5

Enter number of days to simulate: 220

On day 220 you have 10485760 pounds of green crud.

Would you like to continue? (y or n): y

Enter initial amount of green crud: 5

Enter number of days to simulate: 225

On day 225 you have 10485760 pounds of green crud.

Using do while loop

Program:

#include <iostream>

using namespace std;

int main()

{

    char ans;

    do

    {

         //Initial crud size

         int init = 0;

         int newCrud;

         int next=0;

         //Number of days to simulate

         int no_days;

         int day;

         cout << "Enter initial amount of green crud: ";

         cin >> newCrud;

         cout << "Enter number of days to simulate: ";

         cin >> no_days;

         for (day = 10; day<=no_days; day++)

         {

             if (day % 10 == 0)

             {

                  next = newCrud + init;

             }

                  newCrud = init;

                  init = next;

         }

         if (no_days < 5)

         cout << "\nCrud reproduce only after 5 days

         minimum.Hence the current amount is "

         << newCrud << " pounds.";

         else

         

         cout << "On day " << no_days << " you have " <<

         init << " pounds of green crud." << endl;

         cout << "\nWould you like to continue? (y or n):

         ";

         cin >> ans;

    } while (ans == 'Y' || ans == 'y');

    return 0;

}

Output:

Enter initial amount of green crud: 5

Enter number of days to simulate: 220

On day 220 you have 10485760 pounds of green crud.

Would you like to continue? (y or n): y

Enter initial amount of green crud: 5

Enter number of days to simulate: 225

On day 225 you have 10485760 pounds of green crud.

7 0
3 years ago
Calculate the amount of current flowing through a 75-watt light bulb that is connected to a 120-volt circuit in your home.
vodomira [7]

Answer:

I = 0.625 A

Explanation:

Given that,

Power of the light bulb, P = 75 W

Voltage of the circuit, V = 120 V

We need to find the current flowing through it. We know that, Power is given by :

P=V\times I

I is the electric current

I=\dfrac{P}{V}\\\\I=\dfrac{75\ W}{120\ V}\\\\I=0.625\ A

So, the current is 0.625 A.

5 0
2 years ago
What is the difference between a refrigeration cycle and a heat pump cycle?
sukhopar [10]

Answer:

In refrigeration cycle heat transfer from inside refrigeration

In heat pump cycle heat transfer from environment

Explanation:

heat cycle is mechanical process use for cool the temperature but

In refrigeration heat transfer from inside of refrigeration that decrease temperature of refrigerator and in heat pump it decrease temperature negligible as compare to refrigerator

5 0
3 years ago
Other questions:
  • In a fluid power system, if energy is not transferred to work, what form does it take?
    6·1 answer
  • A stem and leaf display
    12·1 answer
  • A long bone is subjected to a torsion test. Assume that the inner diameter is 0.375 in. and the outer diameter is 1.25 in., both
    14·1 answer
  • A reciprocating engine of 750mm stroke runs at 240 rpm. If the length of the connecting rod is 1500mm find the piston speed and
    9·1 answer
  • Crest is to high, as through is to
    12·2 answers
  • Anne-Marie Cole runs the sales division for a local auto insurance firm. One of her key duties is to calculate her company's mar
    11·2 answers
  • How much memory can a 32 -bit processor support ?
    13·1 answer
  • There is a black-box system (i.e we do not know the transfer function of the system). When we fed a step input into the system,
    9·1 answer
  • What is the moment that the wrench puts on the bolt?
    13·1 answer
  • There is a dispute between the multiple parties storing financial transaction data on a blockchain over the validity of a transa
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!