Question

Write a Python program in this Jupyter Notebook. This program will allow a user to choose...

Write a Python program in this Jupyter Notebook. This program will allow a user to choose from a menu to print various text shapes includeing rectangle, triangle, and diamond as well as a set of numbers in a pattern. This program will allow the user to select the type, the size and/or the fill character for a shape. Your program will verify user inputs such as size for certain range specifications, depending on the shapes.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:-

def rectangle(): # function to print the rectangle.
rows = int(input("Please Enter the Total Number of Rows : "))
columns = int(input("Please Enter the Total Number of Columns : "))
ch=input("enter the fill character the shape ")
print("Rectangle ")
for i in range(rows):
for j in range(columns):
print('%c' %ch, end = ' ')
print()
# Function for printing triangle
def triangle(n):
ch=input("enter the fill character the shape ")

k = 2*n - 2
  
# outer loop to handle number of rows
for i in range(0, n):
  
# inner loop to handle number spaces
# values changing acc. to requirement
for j in range(0, k):
print(end=" ")
  
# decrementing k after each loop
k = k - 1
  
# inner loop to handle number of columns
# values changing acc. to outer loop
for j in range(0, i+1):
  
# printing stars
print("%c " %ch, end="")
  
# ending line after each row
print("\r")   
  
  
def Diamond(rows):
ch=input("enter the fill character the shape ")
n = 0
for i in range(1, rows + 1):
# loop to print spaces
for j in range (1, (rows - i) + 1):
print(end = " ")
  
# loop to print star
while n != (2 * i - 1):
print("%c" %ch , end = "")
n = n + 1
n = 0
  
# line break
print()
  
k = 1
n = 1
for i in range(1, rows):
# loop to print spaces
for j in range (1, k + 1):
print(end = " ")
k = k + 1
  
# loop to print star
while n <= (2 * (rows - i) - 1):
print("%c" %ch , end = "")
n = n + 1
n = 1
print()   
  
#function to PRINT NUMBER PATTERN   
def printNos(n):
print("the pattern:\n")
for row in range(1, n+1):
for column in range(1, row + 1):
print(column, end=' ')
print("")

print("************MAIN MENU**************")
print("""Please select your choice -\n
1. print Rectangle\n
2. print traingle\n
3. print diamond\n
4. print the number pattern\n""")
  
  
# Take input from the user
select = input("Select your choice form 1, 2, 3, 4 :")
  

# control the menus using if-else and printing the shape as per users choice
if select == '1':
rectangle()
  
elif select == '2':
s=int(input("enter the size of traingle"))
triangle(s)
  
elif select == '3':
aa=int(input("ENTER THE SIZE OF THE DIAMOND"))
Diamond(aa)
  
elif select == '4':
s=int(input("enter the size of the pattern : \n"))
printNos(s)
  
  

else:
print("Invalid input")
  
  
  

Output:-

* **** ***** **MAIN MENU************** Please select your choice - 1. print Rectangle 2. print traingle 3. print diamond 4. print the no pattern Select your choice form 1, 2, 3, 4 :3 ENTER THE SIZE OF THE DIAMOND10 enter the fill character the shape *

Add a comment
Know the answer?
Add Answer to:
Write a Python program in this Jupyter Notebook. This program will allow a user to choose...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • IN JAVA Overview In this project you will implement a Java program that will print several...

    IN JAVA Overview In this project you will implement a Java program that will print several shapes and patterns according to uses input. This program will allow the use to select the type (say, rectangle, triangle, or diamond), the size and the fill character for a shape. All operations will be performed based on the user input which will respond to a dynamic menu that will be presented. Specifically, the menu will guide the user to decide between different forms...

  • Hello Guys. I need help with this its in java In this project you will implement...

    Hello Guys. I need help with this its in java In this project you will implement a Java program that will print several shapes and patterns according to uses input. This program will allow the use to select the type (say, rectangle, triangle, or diamond), the size and the fill character for a shape. All operations will be performed based on the user input which will respond to a dynamic menu that will be presented. Specifically, the menu will guide...

  • Use Python 3 Create a program that uses Turtle to draw shapes. Show the following menu:...

    Use Python 3 Create a program that uses Turtle to draw shapes. Show the following menu: Enter Circle Enter Rectangle Remove Shape Draw Shapes Exit Circles – User inputs position, radius, and color. The position is the CENTER of the circle Rectangles – User inputs position, height, width, color. The position is the lower left-hand corner Colors – Allow red, yellow, blue, and green only Remove – Show the number of items in the list and let the user enter...

  • Write a short python program in the Jupyter notebook using the TIPS dataset. Take a screenshot...

    Write a short python program in the Jupyter notebook using the TIPS dataset. Take a screenshot of your program as shown on your Python program. The output of your bar chart show look like the image below: 0.20 0.15 tip_rate 0.10 0.05 0.00 Sun Sat Thur Fri day It should show the tip rate on a certain weekdays as shown in the flow chart. Create a ratio column in the Dataframe and the tip rate should be calculated by dividing...

  • Write a C program that does the following: Displays a menu (similar to what you see...

    Write a C program that does the following: Displays a menu (similar to what you see in a Bank ATM machine) that prompts the user to enter a single character S or D or Q and then prints a shape of Square,Diamond (with selected height and selected symbol), or Quits if user entered Q.Apart from these 2 other shapes, add a new shape of your choice for any related character. Program then prompts the user to enter a number and...

  • 1) Write a Python program that prompts the user to enter the current month name and...

    1) Write a Python program that prompts the user to enter the current month name and prints the season for that month. Hint: If the user enters March, the output should be "Spring"; if the user enters June, the output should be "Summer". 2 )Write a Python program using the recursive/loop structure to print out an equilateral triangle below (double spacing and one space between any two adjacent asterisks in the same row).          *      * * * *...

  • Python 3: Please follow the respective rubric for the following function definition. Rubric: Rectangle Shape You...

    Python 3: Please follow the respective rubric for the following function definition. Rubric: Rectangle Shape You should implement the following functions to print a rectangle shape. • print_rectangle(length, width, fillChar, hollow). This function will use draw_shape_line() function to print a rectangle shape with the given length and width, If the hollow is true, the shape will be hollow rectangle, otherwise a filled rectangle. This function must not interact with the user. For example, the call print_rectangle(5, 10, '*', False) should...

  • Write a python programme in a Jupyter notebook which asks the user to input the number...

    Write a python programme in a Jupyter notebook which asks the user to input the number of radioactive nuclei in a sample, the number at a later time, and the elapsed time. The programme should calculate and display the decay constant and the half-life. The decay is described by the equations: ? = ? ?−?? ?0 ?1/2 = ln (2)/? PLEASE INCLUDE COMMENTS ON CODE. THANKS

  • could you write a python code program using version 3 and jupyter notebook to implement DBSCAN...

    could you write a python code program using version 3 and jupyter notebook to implement DBSCAN algorithm?

  • Write a JAVA program to display a “*” triangle and a half diamond of size n,...

    Write a JAVA program to display a “*” triangle and a half diamond of size n, where n is the input of the program. For example, when the user enters 4 as n’s value, the program should print the following shapes of “*”: A triangle of size 4: * *** ***** ******* A half diamond of size 4: * *** ***** ******* ***** *** * Extra Credit (+5) Print the following pattern instead. A triangle of size 4, using *:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT