Learning coding means GreatToCode Be more than a Coder ! Greattocode , Join GreatToCode Community,1000+ Students Trusted On Us .If You want to learn coding, Then GreatToCode Help You.No matter what It Takes !


CODE YOUR WAY TO A MORE FULFILLING And HIGHER PAYING CAREER IN TECH, START CODING FOR FREE Camp With GreatToCode - Join the Thousands learning to code with GreatToCode
Interactive online coding classes for at-home learning with GreatToCode . Try ₹Free Per Month Coding Classes With The Top Teachers . Here are five Python programs to print the multiplication table of a given number

Here are five Python programs to print the multiplication table of a given number

Become More Then A coder | Learn & Start Coding Now.

Here are five Python programs to print the multiplication table of a given number:


### 1. Using a For Loop:

```python
# Program 1: Printing multiplication table using a for loop
number = 5
for i in range(1, 11):
    print(f"{number} * {i} = {number * i}")
```

### 2. Using a While Loop:

```python
# Program 2: Printing multiplication table using a while loop
number = 5
i = 1
while i <= 10:
    print(f"{number} * {i} = {number * i}")
    i += 1
```

### 3. Using a List Comprehension:

```python
# Program 3: Printing multiplication table using list comprehension
number = 5
table = [f"{number} * {i} = {number * i}" for i in range(1, 11)]
for entry in table:
    print(entry)
```

### 4. Using a Generator Expression:

```python
# Program 4: Printing multiplication table using generator expression
number = 5
table_gen = (f"{number} * {i} = {number * i}" for i in range(1, 11))
for entry in table_gen:
    print(entry)
```

### 5. Using a Function:

```python
# Program 5: Printing multiplication table using a function
def multiplication_table(number):
    for i in range(1, 11):
        print(f"{number} * {i} = {number * i}")

number = 5
multiplication_table(number)
```

These programs will print the multiplication table of the given number (in this case, 5) from 1 to 10 using different methods - with a for loop, while loop, list comprehension, generator expression, and a function. You can replace the `number` variable with any desired number to print its multiplication table.

Post a Comment

0 Comments

•Give The opportunity to your child with GreatToCode Kid's • Online Coding Classes for Your Kid • Introduce Your kid To the world's of coding
•Fuel You Career with our 100+ Hiring Partners, Advance Your Career in Tech with GreatToCode. •Join The Largest Tech and coding Community and Fast Forward Your career with GreatToCode. •10000+ Learner's+ 90 % placement Guarantee. • Learning Coding is Better with the GreatToCode community .
•Greattocode Kid's •GreatToCode Career •GreatToCode Interview •GreatToCode Professional •GreatToCode for schools •GreatToCode For colleges •GreatToCods For Businesses.
Are you ready to join the millions of people learning to code? GreatToCode Pass is your one-stop-shop to get access to 1000+ courses, top-notch support, and successful job placement. What are you waiting for? Sign up now and get your future in motion with GreatToCode Pass.