Ex No 3
Ex No 3
Ex. No: 3a
Number Series
Aim
Algorithm
Step 1: Start.
Step 2: Take a value from the user and store it in a variable n.
Step 3: Use a for loop where the value of i ranges between the values of 1 and n.
Step 4: Print the value of i and ‘+’ operator while appending the value of i to a list.
Step 5: Then find the sum of elements in the list.
Step 6: Print ‘=’ followed by the total sum.
Step 7: Stop.
Program
Output
Conclusion
Thus, the python program to calculate the number series is written and executed.
Ex. No: 3b
Number Pattern
Aim
Algorithm
Step 1: Start
Step 2: First, we get the height of the pyramid rows from the user.
Step 3: In the first loop, we iterate from i = 0 to i = rows.
Step 4: In the second loop, we print numbers starting from 1 to j, where j ranges from 0 to i.
Step 5: After each iteration of the first loop, we print a new line.
Step 6: Stop
Program
Output
Conclusion
Thus, the python program to print a number pattern is written and executed.
Ex. No: 3c
Pyramid Pattern
Aim
Algorithm
Step 1: Start
Step 2: The outermost loop starts from i = 1 to i = row + 1.
Step 3: Among the two inner loops, the for loop prints the required spaces for each row using
formula (rows-i)+1, where rows is the total number of rows and i is the current row number.
Step 4: The while loop prints the required number stars using formula 2 * i - 1. This formula
gives the number of stars for each row, where row is i.
Step 5: Stop
Program
Output
Conclusion
Thus, the python program to print the pyramid pattern is written and executed.