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
  • 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...

  • 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

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

    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...

  • Using C++, Write a program that will provide the user a menu from which the user...

    Using C++, Write a program that will provide the user a menu from which the user may select to calculate the area of one of four geometric shapes: a circle, a rectangle, a triangle, and a trapezoid. You should use the most appropriate SWITCH block for this program. The user will input all data needed to calculate the area. The program should output all data input by the user, the calculated area, and the geometric shape selected. Run this program...

  • Write a program in Python that will: Here are following requirements to completing Menu shapes: 1....

    Write a program in Python that will: Here are following requirements to completing Menu shapes: 1. Create a "MENU" with 4 - 5 options have the user click the option and thereafter ask the user to enter the amount of stars from 1 - 50. From there your "for loop" will create the shape. Menu options need to be: 1. Filled Triangle 2. filled Square 3. This can be any shape such as a Square, circle, a different angle of...

  • Using PYTHON create a program to allow the user to enter a phrase or read a...

    Using PYTHON create a program to allow the user to enter a phrase or read a file. Make your program menu-driven to allow the user to select a option to count the total words in the phrase or file. In addition, provide a menu-selection to count the number of words start with a vowel and a selection to count the number of words that start with a consonant. Include exception handlers for file not found, divide by zero, and index...

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
ADVERTISEMENT