Question

Using Python, Can someone please assist in the following:

Summary This weeks lab is to create a simple multiplication table using nested loops and if statements. Prompt the user for

These are the hints:

The outer loop will start each new row. The inner loop will control the display of each column in the row. Note that to keep

Summary This week's lab is to create a simple multiplication table using nested loops and if statements. Prompt the user for the size of the multiplication table (from 2x2 to 10x10). Use a validation loop to display a warning if the number is less than 2 or greater than 10 and prompt the user to enter the data again until they enter a valid number Put a # after any even number in your table (odd numbers will have just a space/nothing after them) Deliverables A source code Python file A Word document containing both source code and the screen print of the program outputs. Lab Steps Sample Output The output should be something similar to the following What size multiplication table would you like? (2- 10): 1 Invalid entry - Enter a number between 2 and 10 What size multiplication table would you like? (2 - 10): 15 Invalid entry - Enter a number between 2 and 10 What size multiplication table would you like? (2 - 10): 10 Multiplication Table 10 x 10) 2 10 10# 8# 10# 12 # 14# 16 # 18# 20 # 30# 8# 12# 16 # 20 # 24 # 28 # 32 # 36 # 40 # 50 # 6# 12# 18 # 24 # 30 # 36 # 42 # 48 # 54 # 60 # 70 # 8# 16# 24 # 32 # 40 # 48 # 56 # 64 # 72 # 80 # 90# 10#20# 30#40# 50# 60# 70# 80# 90#100# 12# 15 20# 25 28# 35 36# 45 18# 21 30# 35 42# 49 54# 63 24# 27 40# 45 56# 63 72# 81 10# 15 14# 21 18# 27
The outer loop will start each new row. The inner loop will control the display of each column in the row. Note that to keep the numbers right-aligned, there are different amounts of space before single digit numbers (those less than 10), double digit numbers (those between 10-99), and triple digit numbers (100) The row labels can be added to your inner loop (note that there are different amounts of space required after the number in the row labels. The column labels should use a separate loop(s) that run before the main outer loop. You can continue printing on the same line using end-" in your print statement. This will come in handy if you want to print several things on one line inside a loop. For example, assuming the value of name is Ada, the following will print "Hello Ada" on one line: print(hello ", end-") print(name, end") Tips: Start early! Do the basic table first without worrying about spacing or lining things up, and don't include row or column headings (add those later) Once you get the numbers in the correct position, think about adding the proper amount of space before each number to line things up Once the columns line up, add the #/space for even odd numbers. Once the basic table is working, then add the row and column headings, and finally the main . Test as you go!
0 0
Add a comment Improve this question Transcribed image text
Answer #1

SOURCECODE:

a=0
while(True):                            #looping until user enters a number between 2 and 10
    a=int(input("What size multiplication table would you like? (2-10): "))
    if(a<2 or a>10):
        print("Invalid entry-Enter a number between 2 and 10")
    else:
        break;
print("\t\t--- Multiplication Table ( ",a,"*",a," ) ---")
print("\t   ",end="")
for i in range(a):
    print(i+1,end="\t   ")       #printing column headers
print("\n")
for i in range(a):
    s="-"
    print(9*s,end="");          #printing spaces after column headers
print("\n")  
for i in range(a):
    if((i+1)<10):       
        print(" ",i+1,"|",end="")       #logic for printing row labels
    else:
        print("",i+1,"|",end="")  
    print("\t",end="")
    for j in range(a):                #logic for printing original Multiplication table of a X a
        m=(i+1)*(j+1)
        if(m<10 and m%2==0):
            print(" ",m,"#",end="\t")   #printing numbers with right aligned
        elif((m>=10 and m<100) and m%2==0):
            print(" ",m,"#",end="\t")   #printing numbers with right aligned
        elif(m>=100 and m%2==0):
           print("",m,"#",end="\t")    #printing numbers with right aligned
        if(m<10 and m%2!=0):
            print(" ",m," ",end="\t") #printing numbers with right aligned
        elif(m>=10 and m%2!=0):
            print(" ",m," ",end="\t") #printing numbers with right aligned
          
    print("\n")

CODE SCREENSHOT:

print(,n,4,end-\t) m%2/-0): ,n, 30 31 32 #printing numbers with right aligned if(m<10 and print( ,end-\t) #printi

OUTPUT1:

What size multiplication table would you like? (2-10): 1 Invalid entry-Enter a number between 2 and 10 What size multiplicati

OUTPUT2:

Add a comment
Know the answer?
Add Answer to:
Using Python, Can someone please assist in the following: These are the hints: Summary This week's lab is to create a simple multiplication table using nested loops and if statements. Prompt the...
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
  • Need some help I am not understanding this programming class at all. We are using Microsoft...

    Need some help I am not understanding this programming class at all. We are using Microsoft visual studio with python in console mode to complete these labs. Double-click to hide white space CIS115 Week 4 Lab Overview Title of Lab: Multiplication Table in Python Summary This week's lab is to create a simple multiplication table using nested loops and if statements. Prompt the user for the size of the multiplication table (from 2x2 to 10x10). Use a validation loop to...

  • Write a Java program that uses nested for loops to print a multiplication table as shown...

    Write a Java program that uses nested for loops to print a multiplication table as shown below. Make sure to include the table headings and separators as shown. The values in the body of the table should be computed using the values in the heading e.g. row 1 column 3 is 1 times 3. * | 1 2 3 4 5 6 7 8 9 4 | 1| 1 2 3 456 7 8 9 2 | 2 4 6.8...

  • Java use for loop (nested for loop) if/else possible on blue J. (row *col)%2 for 0's and 1's.

    Java use for loop (nested for loop) if/else possible on blue J. (row *col)%2 for 0's and 1's. Write a program to generate the below table: . The table should be able to vary in size based on a class constant called SIZE; minimum of 1, maximum of 9. . The O's and 1's can and should be generated by evaluating a mathematical expression using the row and column numbers Think about the operators: +-* / % . The output...

  • Using Html 5: - You are to create a table consisting of 11 rows and 11...

    Using Html 5: - You are to create a table consisting of 11 rows and 11 columns. The table cells are to be 40 pixels wide, each row. The table is to also have a header row that spans across all columns and contains 'Multiplication Math' as the table name. - Alternating rows will have a different background color. - The table is to be centered in the HTML page. The top table row is to have the numbers 1-10...

  • Java Submit a program in a .java file. The program should print a multiplication table for...

    Java Submit a program in a .java file. The program should print a multiplication table for the numbers 1-9. This requires a nested for loop. The outer loop moves from row to row, while the inner loop prints the row. Use tabs to separate the output, such as in the following statement:      System.out.println(“1\t2\t3\t4\t5\t6\t7\t8\t9”); Output should look similar to the following. 1      2     3     4     5     6     7     8     9 ------------------------------------------------------------------ 1       2     3     4     5     6        7     8     9...

  • This program is C++ You have just been offered your first big software contract. The scope...

    This program is C++ You have just been offered your first big software contract. The scope of work is to create a tool for grade school students to learn their times tables. In this program, you will create a 10 x 10 grid of times tables as a cheat sheet for the students to learn. This will display the values of the times tables all the way from 1x1 to 10x10. Make use of formatting tools like inserting tabs, setwidth(),...

  • Write a Python program that tests the function main and the functions discussed in parts a...

    Write a Python program that tests the function main and the functions discussed in parts a through g. Create the following lists: inStock - 2D list (row size:10, column size:4) alpha - 1D list with 20 elements. beta - 1D list with 20 elements. gamma = [11, 13, 15, 17] delta = [3, 5, 2, 6, 10, 9, 7, 11, 1, 8] a. Write the definition of the function setZero that initializes any one-dimensional list to 0 (alpha and beta)....

  • C++ Program - Arrays- Include the following header files in your program:     string, iomanip, iostream Suggestion:...

    C++ Program - Arrays- Include the following header files in your program:     string, iomanip, iostream Suggestion: code steps 1 thru 4 then test then add requirement 5, then test, then add 6, then test etc. Add comments to display assignment //step 1., //step 2. etc. This program is to have no programer created functions. Just do everything in main and make sure you comment each step. Create a program which has: 1. The following arrays created:                 a. an array...

  • Infinite Spiral of Numbers (due 17 Feb 2020) HELLO, WE ARE USING PYTHON 3 TO COMPLETE...

    Infinite Spiral of Numbers (due 17 Feb 2020) HELLO, WE ARE USING PYTHON 3 TO COMPLETE THIS PROJECT!! PLEASE FOLLOW CODE SKELETON AS GIVEN AT THE END. THIS IS DUE 17TH FEB 2020, ANY AND ALL HELP WOULD BE GREATLY APPRECIATED, THANK YOU! Consider the natural numbers laid out in a square spiral, with 1 occupying the center of the spiral. The central 11 x 11 subset of that spiral is shown in the table below. 111 112 113 114...

  • C# 1. Given two lengths between 0 and 9, create an rowLength by colLength matrix with...

    C# 1. Given two lengths between 0 and 9, create an rowLength by colLength matrix with each element representing its column and row value, starting from 1. So the element at the first column and the first row will be 11. If either length is out of the range, simply return a null. For exmaple, if colLength = 5 and rowLength = 4, you will see: 11 12 13 14 15 21 22 23 24 25 31 32 33 34...

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