What is the upper bound of multiplication table? 9 The multiplication table for 2 to 9 2 4 5 6 21 31 4 | 51 6 | 71 81 9 | 4 6 8 10 12 14 16 3 6 9 12 15 18 21 24 18 27 8 12 16 20 24 28 32 36 10 15 20 25 30 35 40 45 12 18 24 30 36 42 48 54 7 8 9 14 21 28 35 42 49 56 63 16 24 32 40 48 56 64 72 18 27 36 45 54 63 72 81

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hello. I'm using nested loops in my python code. 

My code has to be the same as the output provided to us but I'm not sure how to fix the columns or the first row, which should be horizontal, not vertical. I also need to fix the column numbers as they both need to start at 2

**Understanding Multiplication Tables: 2 to 9**

**What is the upper bound of the multiplication table?**

The multiplication table shown here is bounded by the number 9.

**The Multiplication Table for 2 to 9:**

This table illustrates the products of multiplying numbers between 2 and 9:

```
     2   3   4   5   6   7   8   9
---------------------------------
2 |  4   6   8  10  12  14  16  18
3 |  6   9  12  15  18  21  24  27
4 |  8  12  16  20  24  28  32  36
5 | 10  15  20  25  30  35  40  45
6 | 12  18  24  30  36  42  48  54
7 | 14  21  28  35  42  49  56  63
8 | 16  24  32  40  48  56  64  72
9 | 18  27  36  45  54  63  72  81
```

**Explanation:**

- The numbers across the top (2 to 9) are multipliers.
- The numbers down the left (2 to 9) are the multiplicands.
- The intersections of the rows and columns show their products. For example, in the row labeled "2," multiplying 2 by the numbers 2 through 9 gives the products listed in that row.
Transcribed Image Text:**Understanding Multiplication Tables: 2 to 9** **What is the upper bound of the multiplication table?** The multiplication table shown here is bounded by the number 9. **The Multiplication Table for 2 to 9:** This table illustrates the products of multiplying numbers between 2 and 9: ``` 2 3 4 5 6 7 8 9 --------------------------------- 2 | 4 6 8 10 12 14 16 18 3 | 6 9 12 15 18 21 24 27 4 | 8 12 16 20 24 28 32 36 5 | 10 15 20 25 30 35 40 45 6 | 12 18 24 30 36 42 48 54 7 | 14 21 28 35 42 49 56 63 8 | 16 24 32 40 48 56 64 72 9 | 18 27 36 45 54 63 72 81 ``` **Explanation:** - The numbers across the top (2 to 9) are multipliers. - The numbers down the left (2 to 9) are the multiplicands. - The intersections of the rows and columns show their products. For example, in the row labeled "2," multiplying 2 by the numbers 2 through 9 gives the products listed in that row.
```python
# Author: Rahma Seid
# Course: CSCI 1170-001
# Assignment: CLA12
# The purpose of this number is to find the range
# between 2 and 20. Demonstrate nested Loops

rows = int(input("What is the upper bound of multiplication table: "))
print(f"The multiplication table from 2 to {rows}.")

print("----------")
print(" ", end=" ")

for r in range(2, rows+1):
    print(r)
    print(" ", end=" ")

print("----------")
print(" ", end=" ")

for c in range(1, rows+1):
    for r in range(2, rows+1):
        print(r * c, end=" ")
        r += 1
    print()
```

**Explanation of the Program:**

1. **Purpose:** 
   - The program generates a multiplication table from 2 up to a user-defined upper bound. This table is designed to utilize nested loops for educational purposes.

2. **Code Breakdown:**
   - **Input:**
     - The user is prompted to enter an upper bound for the multiplication table, which should be an integer.
   - **Output:**
     - A multiplication table starting from 2 up to the user-defined upper bound is printed.

3. **Structure:**
   - The program starts by asking for user input and stores it in the variable `rows`.
   - It then prints the headers using a for-loop from 2 to `rows`.
   - Two nested loops are used:
     - The outer loop iterates over the range from 1 to `rows`.
     - The inner loop iterates from 2 to `rows`, multiplying the outer loop variable (`c`) by the inner loop variable (`r`), and prints the result.
   - This nested looping effectively generates and displays the multiplication table from 2 up to the upper limit specified by the user.

4. **Concept Highlighted:**
   - The program demonstrates the use of nested loops to construct a multiplication table, which serves as an example of how loops can be applied in practical scenarios.
Transcribed Image Text:```python # Author: Rahma Seid # Course: CSCI 1170-001 # Assignment: CLA12 # The purpose of this number is to find the range # between 2 and 20. Demonstrate nested Loops rows = int(input("What is the upper bound of multiplication table: ")) print(f"The multiplication table from 2 to {rows}.") print("----------") print(" ", end=" ") for r in range(2, rows+1): print(r) print(" ", end=" ") print("----------") print(" ", end=" ") for c in range(1, rows+1): for r in range(2, rows+1): print(r * c, end=" ") r += 1 print() ``` **Explanation of the Program:** 1. **Purpose:** - The program generates a multiplication table from 2 up to a user-defined upper bound. This table is designed to utilize nested loops for educational purposes. 2. **Code Breakdown:** - **Input:** - The user is prompted to enter an upper bound for the multiplication table, which should be an integer. - **Output:** - A multiplication table starting from 2 up to the user-defined upper bound is printed. 3. **Structure:** - The program starts by asking for user input and stores it in the variable `rows`. - It then prints the headers using a for-loop from 2 to `rows`. - Two nested loops are used: - The outer loop iterates over the range from 1 to `rows`. - The inner loop iterates from 2 to `rows`, multiplying the outer loop variable (`c`) by the inner loop variable (`r`), and prints the result. - This nested looping effectively generates and displays the multiplication table from 2 up to the upper limit specified by the user. 4. **Concept Highlighted:** - The program demonstrates the use of nested loops to construct a multiplication table, which serves as an example of how loops can be applied in practical scenarios.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Binary numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education