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.