Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help changing my Python code so that the output looks exactly as below: My program is as follows: def main(): # Description of

I need help changing my Python code so that the output looks exactly as below:

image text in transcribed

My program is as follows:

def main(): # Description of the program print("This program creates and displays a spaced multiplication") print("and division table based on user input.") print("="*57) print()

# Prompt the user for column starting value C1=int(input("Enter column starting value (C1): "))

# Prompt the user for column increment CX=int(input("Enter column increment (CX): ")) print() # Prompt the user for row starting value N1=int(input("Enter row starting value (N1): ")) # Prompt the user for row ending value N2=int(input("Enter row ending value (N2): ")) # Prompt the user for row increment NX=int(input("Enter row increment (NX): ")) print()

#Display multiplication table header print(" Multiplication Table") print("\t", end = " ") row=[1] for i in range(10): num=C1+CX*i print(num, end = "\t") row.append(num) print() print("="*85)

# Determine multiplicands for num in range(N1, N2+1, NX): for multiplier in row: print(num*multiplier, end= "|\t") print() print("="*85) print() # Display divsion table header print(" Division Table") print("\t", end = " ") row=[1] for i in range(10): num=C1+CX*i print(num, end = "\t") row.append(num) print() print("="*85)

# Determine dividends for num in range(N1, N2+1, NX): for dividends in row: print(num/dividends, "%.3f" %dividends, end= "|\t") print() print("="*85) print()

# Call the main function main()

My program runs and displays the tables but I need to add commas to the numbers in the multiplication table and limit the number of decimal places to 3 in the division table.

This program creates and displays a spaced multiplication and division table based on user input Enter column starting value (C1): 2 Enter column increment (CX): 5 Enter row starting value (N1): 105 Enter row ending value (N2): 135 Enter row increment (NX): 2 Multiplication Table 37 105 10735 1,2601,785 2,310 2,835 3,360 I 3,885 4,410 1 4,935 I 107 214 7491,284 1,819 2,354 2,889 3,424 3,9594,4941 5,029 I 109 218 763 1 1,308 1,853 2,398 2,9431 3,488 I 4,033 4,578 I 5,123 I 111 222 7771 1,332 1,887 2,442 2,997 3,552 4,107 4,662 1 5,217 I 113 226 791 1,356 1,921 2,486 3,051 3,616 4,181 4,7461 5,311 I 115 230 80 1,380 1,955 2,530 3,105 3,680 4,255 4,830I 5,405 I 117 234 819 1,404 1,989 2,574 3,159 3,744 4,329 4,914 5,499 I 119 238 8331,428 2,023 2,618 3,2131 3,808 1 4,483 4,998 1 5,593 I 121 242 847 1,452 2,0571 2,662 3,267 3,872 4,4771 5,0821 5,687 I 123 2468611,476 2,091 2,706 3,323,936 4,551I 5,1665,781 I 125 250 875 1 1,500 2,125 2,750 3,375 4,0001 4,625 5,250 5,875 I 127 2541 889 1,524 2,159 2,794 3,429 4,0641 4,6995,334 5,969 I 129 2581 90311,548 2,193 2,838 3,483 4,128 I 4,773 1 5,418 6,063 I 131 262 917 1,572 2,227 1 2,882 3,537 4,192 4,8471 5,502 1 6,157 I 133 266 931 1,5962,261 2,926I 3,5911 4,256 1 4,921 5,586 1 6,251 I 135 278 I 945 I 1,620 I 2,295 I 2,970 I 3,645 I 4,3201 4,995 I 5,6701 6,3451 Division Table 12 37 105 I 52.500 15.000 1 8.750 6.1761 4.773 1 3.889 3.281 2.838 2.500 2.234 I 107 53.500 15.286 8.917 6.2941 4.864 1 3.963 3.344 2.892 2.5481 2.277 109 I 54.500 15.571I 9.083 6.4124.955 4.837 3.406 2.946 2.595 2.319 I 111 55.500 15.857I 9.250 6.529I 5.045 4.111 3.469 3.000 2.643 2.362 I 113 I 56.500 16.1431 9.417 6.647 5.136 4.185 1 3.5313.054 2.6902.404 I 115 1 57.500 16.429 1 9.583 6.765 5.2271 4.259 3.5941 3.108 2.7381 2.447 117 58.500 16.714 9.750 6.882 5.318 4.333 3.656 3.162 2.7862.489 119 59.500 17.000 I 9.917 7.000 I 5.409 I 4.407 3.719 3.216 2.833 2.532 I 121 I 60.500 17.286 I 10.0837.118 5.500 4.481 1 3.7813.270 2.881 2.574 123 61.500 17.571 I 10.250 7.235 5.591 I 4.556 3.844 1 3.324 2.929 2.617 125 62.580 17.857 10.417 7.353 5.682 4.630 3.906 3.378 2.976 2.660 I 127 63.500 18.143 I 10.583 7.471 I 5.773 4.704 I 3.969 3.432 3.024 2.702 I 129 1 64.500 I 18.429 10.750 7.588 5.8641 4.7781 4.031 3.486 3.071 2.745 I 131 65.500 18.714 I 10.917 7.7061 5.955 1 4.852 4.094 I 3.541 3.119 2.787 133 66.500 19.000 I 11.083 7.824 6.045 4.926 4.156 3.595 3.167 2.830 I 135 1 67.500 19.286 11.2507.941 6.136 5.000 4.219 3.649 3.214 2.872

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

5-4 What are the current computer software platforms and trends?

Answered: 1 week ago

Question

5. Benchmark current training practices.

Answered: 1 week ago