Welcome to Python World!

Learn Coding Step by Step ๐Ÿš€

A fun beginner programming course for young programmers
Created by Geta Ba / GETCOM

๐ŸŽฏ What Will You Learn Today?

๐Ÿ” Example 16: Print Numbers 1 to 10 Using For Loop

Python repeats instructions using a for loop.

๐Ÿ Python Code



# Example 16
# Print numbers from 1 to 10


for i in range(1,11):

    print(i)


๐Ÿค– Python Output

1

2

3

4

5

6

7

8

9

10 โœ…

โญ Challenge:
Change the program to print numbers from 1 to 20.

โญ Example 17: Multiplication Table Using For Loop

Python creates multiplication tables automatically.

๐Ÿ Python Code



number=int(input("Enter Number: "))


for i in range(1,11):

    print(number,"x",i,"=",number*i)



๐Ÿค– Python Output

Enter Number: 5


5 x 1 = 5

5 x 2 = 10

5 x 3 = 15

5 x 10 = 50 โญ

๐ŸŽฏ Challenge:
Create multiplication table for 12.

โž• Example 18: Sum of Numbers Using For Loop

Python can calculate totals automatically.

๐Ÿ Python Code



total=0


for i in range(1,101):

    total=total+i


print("Total =",total)



๐Ÿค– Python Output

Total = 5050

๐Ÿš€ Project:
Find the sum from 1 to 1000.

๐Ÿ“ Example 19: Square Numbers

Python calculates square values using loops.

๐Ÿ Python Code



for i in range(1,11):

    print(i,"Square =",i*i)



๐Ÿค– Python Output

1 Square = 1

2 Square = 4

3 Square = 9

10 Square = 100

โญ Challenge:
Create a cube number program.

๐Ÿ”ข Example 20: Even Numbers Using For Loop

Python uses loops to display only even numbers.

๐Ÿ Python Code



# Example 20
# Print Even Numbers from 1 to 20


for i in range(1,21):

    if i % 2 == 0:

        print(i)



๐Ÿค– Python Output

2

4

6

8

10

12

14

16

18

20 โœ…

โญ Challenge:
Modify the program to print odd numbers from 1 to 50.

๐ŸŽ„ Example 21: Star Pattern Using For Loop

Python can create beautiful patterns using loops.

๐Ÿ Python Code



# Example 21
# Create Star Pattern


for i in range(1,6):

    print("*" * i)



๐Ÿค– Python Output

*

**

***

****

*****

๐ŸŽฏ Challenge:
Create a pattern with 10 rows.

๐Ÿ”ป Example 22: Inverted Star Triangle

Python decreases stars in every loop.

๐Ÿ Python Code



for i in range(5,0,-1):

    print("*" * i)

๐Ÿค– Python Output

*****

****

***

**

*

๐ŸŽฏ Challenge: Reverse the pattern.

๐Ÿ”บ Example 23: Pyramid Star Pattern

Python creates a centered pyramid shape.

๐Ÿ Python Code



for i in range(1,6):

    print(" "*(5-i) + "*"*(2*i-1))

๐Ÿค– Python Output

*

***

*****

*******

*********

โญ Challenge: Create a pyramid with 10 levels.

๐Ÿ’Ž Example 24: Diamond Star Pattern

Python combines two loops to create a diamond.

๐Ÿ Python Code



for i in range(1,6):

    print(" "*(5-i)+"*"*(2*i-1))


for i in range(4,0,-1):

    print(" "*(5-i)+"*"*(2*i-1))

๐Ÿค– Python Output

*

***

*****

*******

*********

*******

*****

***

*

๐Ÿš€ Project: Create a bigger diamond.

โฌœ Example 25: Square Star Pattern

Python creates rows and columns using loops.

๐Ÿ Python Code



for i in range(5):

    print("* "*5)

๐Ÿค– Python Output

* * * * *

* * * * *

* * * * *

* * * * *

* * * * *

โญ Challenge: Create a 10 x 10 square.

๐Ÿ”ข Example 26: Number Star Pattern

Python can print numbers using loops.

๐Ÿ Python Code



for i in range(1,6):

    for j in range(i):

        print(i,end=" ")

    print()

๐Ÿค– Python Output

1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

๐Ÿš€ Project: Create your own pattern design.