(Python)(Display four patterns using loops) Use nested loops that display the following patterns in four separate programs: *TUTOR INSTRUCTIONS* I have the code for all four patterns but for some reason the code is going downward instead of horizontally as shown in the provided image. Could you please just double check my coding and see how I can make it horizontal or if I need to seperate each pattern a certain way. The coding for this problem is: def numpat(n): # initialising starting number num = 1 # outer loop to handle number of rows for i in range(0, n): # re assigning num num = 1 # values changing acc. to outer loop for j in range(0, i + 1): print(num, end=" ") num = num + 1 # ending line after each row print("\r") n = 6 numpat(n) # iterate from 6 to 1 for i in range(6, 0, -1): # iterate from 1 to i+1 # since end value is exclusive, so adding 1 to i for j in range(1, i + 1): # print current value of j # set end to a space to print space after each value print(j, end=' ') # change the line after each iteration of outer loop print() n = 6 k = 2*n - 2 for i in range(0,n+1): for j in range(0,k+2): print(end=" ") k = k - 2 for j in range(1,i+1): print(i-j+1, end=" ") print() n = 6 for i in range(n, 0 , -1): for j in range(1, i + 1): print(j, end="") print('')

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

(Python)(Display four patterns using loops) Use nested loops that display the following patterns in four separate programs:

*TUTOR INSTRUCTIONS*

I have the code for all four patterns but for some reason the code is going downward instead of horizontally as shown in the provided image. Could you please just double check my coding and see how I can make it horizontal or if I need to seperate each pattern a certain way. The coding for this problem is:

def numpat(n):
# initialising starting number
num = 1

# outer loop to handle number of rows
for i in range(0, n):

# re assigning num
num = 1

# values changing acc. to outer loop
for j in range(0, i + 1):
print(num, end=" ")

num = num + 1

# ending line after each row
print("\r")


n = 6
numpat(n)


# iterate from 6 to 1
for i in range(6, 0, -1):
# iterate from 1 to i+1
# since end value is exclusive, so adding 1 to i
for j in range(1, i + 1):
# print current value of j
# set end to a space to print space after each value
print(j, end=' ')

# change the line after each iteration of outer loop
print()

n = 6
k = 2*n - 2

for i in range(0,n+1):
for j in range(0,k+2):
print(end=" ")

k = k - 2
for j in range(1,i+1):
print(i-j+1, end=" ")
print()

n = 6

for i in range(n, 0 , -1):
for j in range(1, i + 1):
print(j, end="")
print('')

 

 

 

 

 

Pattern A
Pattern B
Pattern C
Pattern D
1.
1 2
123
123 4
1 2 3 45
1 2 3 45 6
12345 6
12345
1234
123
1 2
12345 6
1 2 3 4 5
1 2 3 4
123
1 2
1
2 1
321
4 3 2 1
5 4 3 2 1
6 5 4 3 2 1
1
Transcribed Image Text:Pattern A Pattern B Pattern C Pattern D 1. 1 2 123 123 4 1 2 3 45 1 2 3 45 6 12345 6 12345 1234 123 1 2 12345 6 1 2 3 4 5 1 2 3 4 123 1 2 1 2 1 321 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1 1
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 8 images

Blurred answer
Knowledge Booster
Literals
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education