Question

PYTHON 1.      Complete the attached template program pattenrs.py to create and display a number of patterns. The...

PYTHON

1.      Complete the attached template program pattenrs.py to create and display a number of patterns. The program works with a single digit. The default value is 6, but user to change it as a menu selection.

2.      Program should display the patterns below. Additionally, you need to create your own pattern.

3.      Do not modify myPatterns6 driver.

4.      Make sure you document the program and its functions.

5.      PatternI is already implemented.

6.      Create five additional functions (similar to PatternI function) to implement Patterns II, III, IV, V, and VI (your own).

7.      Use nested loops to print the other patterns and the pattern of your own choice.

Pattern I          Pattern II         Pattern III                   Pattern IV       Pattern V      Your Own

1                      123456                           6                  123456            12345654321

12                    12345                           56                   23456              234565432

123                  1234                           456                      3456                3456543

1234                123                          3456                       456                  45654

12345              12                           23456                         56                    565

123456            1                           123456                            6                      6

Homework Answers

Answer #1

def p1(n):

    for i in range(0,n):

        for j in range(1,i+2):

            print(j,end="")

        print()

        

def p2(n):

    for i in range(n-1,-1,-1):

        for j in range(1,i+2):

            print(j,end="")

        print()

        

def p3(n):

    for i in range(n-1,-1,-1):

        for j in range(1,i+1):

            print(" ",end="")

        for j in range(i+1,n+1):

            print(j,end="")    

        print()

        

def p4(n):

    for i in range(0,n):

        for j in range(1,i+1):

            print(" ",end="")

        for j in range(i+1,n+1):

            print(j,end="")      

        print()

        

def p5(n):

    for i in range(0,n):

        for j in range(1,i+1):

            print(" ",end="")

        for j in range(i+1,n+1):

            print(j,end="")

        for j in range(n-1,i,-1):

            print(j,end="")

        print()

        

n=int(input("Enter a number: "))

p1(n)

print("\n\n")

p2(n)

print("\n\n")

p3(n)

print("\n\n")

p4(n)

print("\n\n")

p5(n)

print("\n\n")

#SAMPLE OUTPUT

PLEASE LIKE IT RAISE YOUR THUMBS UP
IF YOU ARE HAVING ANY DOUBT FEEL FREE TO ASK IN COMMENT SECTION

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create Sample Menu for Elementary School a. Create a single day’s replacement menu providing healthier choices...
Create Sample Menu for Elementary School a. Create a single day’s replacement menu providing healthier choices for each menu analyzed, including the following. i. Breakfast, lunch, and dinner options   ii. Age considerations iii. Potential health concerns iv. Cultural influences v. Regional patterns vi. Nutritional components of your food choices vii. Two references that support your choices included on the slide or in the speaker’s notes
Create a program that generates a file of random numbers, and then prints them in neat...
Create a program that generates a file of random numbers, and then prints them in neat fashion to another file, and also saves to that file the average and standard deviation of those numbers. I) First, you would need to generate a file of random numbers that consists of N random numbers (100 < N < 1000). Each random digit should be a real number (type double) between 0 and 50. This file and its digits would now serve as...
Program Assignment 1: Process Management Objective: This program assignment is given to the Operating Systems course...
Program Assignment 1: Process Management Objective: This program assignment is given to the Operating Systems course to allow the students to figure out how a single process (parent process) creates a child process and how they work on Unix/Linux(/Mac OS X/Windows) environment. Additionally, student should combine the code for describing inter-process communication into this assignment. Both parent and child processes interact with each other through shared memory-based communication scheme or message passing scheme. Environment: Unix/Linux environment (VM Linux or Triton...
1. Please use only the C as the language of programming. 2. Please submit/upload on Canvas,...
1. Please use only the C as the language of programming. 2. Please submit/upload on Canvas, the following les for each of your programs: (1) the client and the server source les each (2) the client and the serve executable les each (3) a brief Readme le that shows the usage of the program. 3. Please appropriately comment your program and name all the identiers suitable, to enable enhanced readability of the code. Problems 1. Write an ftp client that...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT