Question

In: Computer Science

Write a program in python that will produce this outcome. Project 2: Developed by Yourname 0....

Write a program in python that will produce this outcome.

Project 2: Developed by Yourname

0. Exit
1. Print a Diamond
2. Print a Number Pattern
3. Print a cost table
Enter your choice:
1
Enter the length (an even number between 0 and 20): -1
Enter the length (an even number between 0 and 20): 3
Enter the length (an even number between 0 and 20): 22
Enter the length (an even number between 0 and 20): 10
Enter the char used left to the diamond: *
Enter the char used to fill the diamond: T
\TTTTTTTT/
*\TTTTTT/
**\TTTT/
***\TT/
****\/
****/\
***/TT\
**/TTTT\
*/TTTTTT\
/TTTTTTTT\


0. Exit
1. Print a Diamond
2. Print a Number Pattern
3. Print a cost table
Enter your choice:
3
Enter the maximum quantity (between 1 and 9): 0
Do you want horizontal (item\qnty) table (Yes or No): Yes
Cost Table
Item\Qty
Beans   
Rice
Banana
Ice   
Tea   
Bread   
Orange
Sugar   


0. Exit
1. Print a Diamond
2. Print a Number Pattern
3. Print a cost table
Enter your choice:
3
Enter the maximum quantity (between 1 and 9): 5
Do you want horizontal (item\qnty) table (Yes or No): No
Cost Table
Qty\Item Beans Rice Banana Ice Tea Bread Orange Sugar
1 3.25 4.31 6.88 3.30 5.25 4.89 6.32 2.25
2 6.50 8.62 13.76 6.60 10.50 9.78 12.64 4.50
3 9.75 12.93 20.64 9.90 15.75 14.67 18.96 6.75
4 13.00 17.24 27.52 13.20 21.00 19.56 25.28 9.00
5 16.25 21.55 34.40 16.50 26.25 24.45 31.60 11.25


0. Exit
1. Print a Diamond
2. Print a Number Pattern
3. Print a cost table
Enter your choice:
3
Enter the maximum quantity (between 1 and 9): 4
Do you want horizontal (item\qnty) table (Yes or No): Yes
Cost Table
Item\Qty 1 2 3 4
Beans 3.25 6.50 9.75 13.00
Rice 4.31 8.62 12.93 17.24
Banana 6.88 13.76 20.64 27.52
Ice 3.30 6.60 9.90 13.20
Tea 5.25 10.50 15.75 21.00
Bread 4.89 9.78 14.67 19.56
Orange 6.32 12.64 18.96 25.28
Sugar 2.25 4.50 6.75 9.00


0. Exit
1. Print a Diamond
2. Print a Number Pattern
3. Print a cost table
Enter your choice:
0
Thank you for using this program. Bye.

Solutions

Expert Solution

while True:
print("0. Exit\n1. Print a Diamond\n2.Print a Number Pattern\n3.Print a cost table\nEnter your choice:")
c=int(input()) #read the choice
if c==0: #if choice=0 break the loop
print("Thank you for using this program. Bye.")
break
elif c==1: #c=1 for print the diamond
print("Enter the length (an even number between 0 and 20):",end="")
ch=int(input()) #read the integer for no of lines
while ch<=0 or ch>20: #if ch is not between 0 and 20 ,repeat the loop
print("Enter the length (an even number between 0 and 20):",end="")
ch=int(input())
print("Enter the char used left to the diamond:",end="")
a=input()
print("Enter the char used to fill the diamond:",end="")
b=input()
k=ch #k represents number of symbols represent diamond
for i in range(ch//2): #loop for half of diamond
print(a*i+'\\'+b*(k-2)+'/')
k=k-2 #k decrements by 2 for every iteration upto half of the diamond
for j in range(ch//2,0,-1): #loop for remianing half of diamond
print(a*(j-1)+'/'+b*k+'\\')
k=k+2 #k increments by 2 for every iteration upto half of the diamond
elif c==2:
pass #in the quetion, they didnt mention the number pattern example.
elif c==3:
#items list
items=["Beans", "Rice", "Banana", "Ice", "Tea", "Bread", "Orange", "Sugar"]
#price list
lt=[3.25, 4.31, 6.88, 3.30, 5.25, 4.89, 6.32, 2.25]
print("Enter the maximum quantity (between 1 and 9): ",end="")
q=int(input())
print("Do you want horizontal (item\qnty) table (Yes or No): ",end="")
r=input()
print("Cost Table")
if r=="Yes":
print("Item/Qnty",end=" ")
for i in range(1,q+1):
print(i,end=" ") #print quantities
print()
for i in range(len(items)):
print(items[i],end=" ") #print items
for j in range(1,q+1):
print("{0:.2f}".format(lt[i]*j),end=" ") #cost of items
print()
elif r=="No":
print("Qnty/Item",end=" ")
for i in items:
print(i,end=" ") #print items
print()
for j in range(1,q+1):
print(j,end=" ") #print quantities
for k in range(len(lt)):
print("{0:.2f}".format(lt[k]*j),end=" ") #print cost of items
print()
  
  
output:


Related Solutions

Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a numeric grade (on a scale of 0-100) from the user and convert it to a letter grade based on the following table. A: 90% - 100% B 80% - 89% C 70% - 79% D 60% - 69% F <60% The program should be written so that if the user entered either a non-numeric input or a numeric input out of the 0-100 range,...
Write a program in Python that will print first 100 numbers of the following series: 0,...
Write a program in Python that will print first 100 numbers of the following series: 0, 1, 1, 2, 3, 5, 8……..
In python write a program that first creates a list with the integers 0 through 9...
In python write a program that first creates a list with the integers 0 through 9 and then traverses that list RECURSIVELY (no for/while loops allowed) and prints out the integers on the list. NOTE: creating the list does not have to be done recursively.
Write a Python program which generates a random number between 0 and 24 inclusive and that...
Write a Python program which generates a random number between 0 and 24 inclusive and that print out: • the double of the random number if the random number is greater than 12, • the triple of the random number if it is equal to 12 • and the quadruple of the random number if it is less than 12
Program must be in Python Write a program in Python whose inputs are three integers, and...
Program must be in Python Write a program in Python whose inputs are three integers, and whose output is the smallest of the three values. Input is 7 15 3
Calculating Delivery Cost Program in Python write a program in Python that will ask a user...
Calculating Delivery Cost Program in Python write a program in Python that will ask a user to enter the purchase total, the number of the items that need to be delivered and delivery day. Then the system displays the cost of delivery along with the total cost. Purchase total > $150 Yes Number of the items (N) N<=5 N>=6 Delivery day Same Day Next Day Same Day Next Day Delivery charges ($) 8 N * 1.50 N * 2.50 N...
Python Language: Similar to Project 3, write a program that loops a number from 1 to...
Python Language: Similar to Project 3, write a program that loops a number from 1 to 10 thousand and keeps updating a count variable according to these rules: if the number is divisible by n1, increase count by 1 if the number is divisible by n2, increase count by 2 if the number is divisible by n3, increase count by 3 if none of the above conditions match for the number, increase count by the number. Before the loop begins,...
For Python: In this assignment you are asked to write a Python program to determine the...
For Python: In this assignment you are asked to write a Python program to determine the Academic Standing of a studentbased on their CGPA. The program should do the following: Prompt the user to enter his name. Prompt the user to enter his major. Prompt the user to enter grades for 3 subjects (A, B, C, D, F). Calculate the CGPA of the student. To calculate CGPA use the formula: CGPA = (quality points * credit hours) / credit hours...
In python. Projectile motion: Write a python program that will ask the user for      an...
In python. Projectile motion: Write a python program that will ask the user for      an initial height y0, initial velocity v, launch angle theta, and mass m.      Create two functions, one that will calculate max height      of the projectile, and one that will calculate the range. Ask the     user which one he/she would like to calculate, then present them with the answer. (use kg, m and m/s)
Write a program in python language, which accepts 2 numbers and a + sign (for addition)...
Write a program in python language, which accepts 2 numbers and a + sign (for addition) A sign - (for subtraction) A sign * (for multiplication), / (for division) Then calculate and to display the result of the operation he chose with the two numbers. Displaying the appropriate message
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT