Answer:
see explaination
Step-by-step explanation:
Program source code below:
def displayNumbers():
string = ""
num = 0
#first loop to control 5 rows
for i in range(5):
#second loop to control columns
for j in range(5):
str1 = str(num)
# str1.ljust(5) function to left justify output string
#appending number in resulting string
string = string + str1.ljust(5)
#updating num for next iteration
num = num + 1
#new line after each row to display pattern correctly
string = string + "\\"
return string
def pattern():
string = ""
num = 0
#first loop to control 1-4 rows
for i in range(5):
#In second loop to control 5 columns
for j in range(5):
str1 = str(num)
if num == 2:
num = num -2
else :
num = num + 1
# str1.ljust(5) function to left justify output string
string = string + str1.ljust(5)
# new line after each row to display pattern correctly
string = string + "\\"
return string
#Function calls
print('\033[4m')
print('\033[1m{}\033[0m'.format('Output 1:\\'))
print(displayNumbers())
print('\033[4m')
print('\u0332\033[1m{}\033[0m'.format('Output 2:\\ew'))
print(pattern())
See attachment for sample output and screenshot.
Nb: Always refer to screenshot if there is an indentation error.