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
MA_775_DIABLO [31]
3 years ago
9

The PadRight function has two parameters: S (a string) and N (an int), and returns as its result the string S padded on the righ

t with blanks until the length of S contains no fewer than N characters. The PadLeft function is identical to PadRight except that it adds blanks to the left side of the string. For example, the string "Frog" is four characters long, so PadLeft("Frog",7) would return the
Computers and Technology
1 answer:
oee [108]3 years ago
6 0

Answer:

The following code is written in python programming language:

def PadRight(S,N):   #define user defined function

 if(len(S)<N):    # set if condition

   S=S.ljust(N)   #set the space to right

   return S       # return the result

 

def PadLeft(S,N):    #define user defined function

 if(len(S)<N):    # set if condition

   S=S.rjust(N)   # set the space to left

   return S       # return the result

'''calling the function'''

print(PadLeft("Frog",7))

print(PadRight("Frog",7))

Output:

      Frog

Frog

Explanation:

Here, we define a user defined function "PadRight()" and pass two arguments in its parameter "S", "N".

Then, set the if condition and pass condition "len(S)<N" then, if the condition is true then the code inside the if condition set the space to right then, return the output.

After that, we again define a user defined function "PadLeft()" and pass two arguments in its parameter "S", "N".

Then, set the if condition and pass condition "len(S)<N" then, if the condition is true then the code inside the if condition set the space to right then, return the output.

You might be interested in
Zoe wants to post something controversial online, but then she remembers that employers may look at her social media when she st
allsm [11]

Answer:

D

Explanation:

7 0
2 years ago
When copper wires are bundled together, they are susceptible to ____________, a form of interference where the signals leak out
maksim [4K]

Answer:

crosstalk

Explanation:

6 0
1 year ago
Write a class Bug that models a bug moving along a horizontal line. The bug moves either to the right or left. Initially, the bu
Harrizon [31]

Answer:

Explanation:

The following code is written in Java. It creates the Bug class with the position and direction variables. Then it creates a constructor, move method, turn method, and getPosition method. Finally, a bug object called bugsy is created in the main method, and we move it once to the right, then again to the right, and then we turn it and move it 5 times to the left, printing out the position when it is done moving. Output can be seen in the attached picture below.

class Brainly {

   public static void main(String[] args) {

       Bug bugsy = new Bug(10);

       bugsy.move();

       System.out.println("Current bug position: " + bugsy.getPosition());

       bugsy.move();

       System.out.println("Current bug position: " + bugsy.getPosition());

       bugsy.turn();

       bugsy.move();

       bugsy.move();

       bugsy.move();

       bugsy.move();

       bugsy.move();

       System.out.println("Current bug position: " + bugsy.getPosition());

   }

}

class Bug {

   char direction = 'r';

   int position = 0;

   public Bug(int initialPosition) {

       this.position = initialPosition;

   }

   public void turn() {

       if (this.direction == 'r') {

           this.direction = 'l';

       } else {

           this.direction = 'r';

       }

   }

   public void move() {

       if (this.direction == 'r') {

           this.position += 1;

       } else {

           this.position -= 1;

       }

   }

   public int getPosition() {

       return this.position;

   }

}

7 0
3 years ago
What will be displayed after the following code is executed? def pass_it(x, y): z = x*y result = get_result(z) return(result) de
Rus_ich [418]

Answer:

The output of the following code is "14".  

Explanation:

In the python program firstly we define a function that is  pass_it() function. In this function, we pass the two variable that is x,y. Then we define two variable z and result in the function. The z variable is used to store the multiplication value of the x,y. In the result variable, we use another function that is get_result() function in this function we pass the value of the z variable as a parameter. This function adds a value that is 2 and returns its value. Then we declare a variable that is num1 and num2. In this variable, we assign value that is 3 and 4 and return value of the pass_it() function in the answer variable and print it.  

7 0
3 years ago
Why do we need to send emails
DiKsa [7]

Answer:

email is the easier way of communicating and fast

5 0
3 years ago
Other questions:
  • Janice, who is 15, posts a picture of herself drinking alcohol and making an obscene gesture on her social networking page. Whic
    11·2 answers
  • In ancient times what did kings and tribals chiefs use to communicate
    10·1 answer
  • Why should ERP architecture include a discussion on organizational structure, business processes, and people, instead of just in
    5·1 answer
  • I will give brainliest!!!
    13·1 answer
  • Write a C# program named DoubleDecimalTest thatdeclares and displays two variables - a double and a decimal.Experiment by assign
    9·1 answer
  • 19 dollar fortnite gift card
    14·2 answers
  • What are 3 similarities and 3 differences between live theatre and film/videos -Drama Class
    13·1 answer
  • Select the correct answer from each drop-down menu. A company is recruiting for a web designer. What kind of candidate should th
    14·2 answers
  • it is good to know and use the npsd framework while solution envisioning as part of the value discovery cycle. What is NPSD?
    10·1 answer
  • Write a two to three sentence response to the following question:
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!