Python- ITERATIVE STATEMENT

Good Morning Boys




Today we will continue our discussion regarding ITERATIVE statements also called LOOPING.
-----------------------------------------------------------------------------------------------------------------
Today we will take a review of FOR loop and build on how to find SUM and PRODUCT using FOR loop

-------------------------------------------------------------------------------------------------------------------
The Google meet link fro today's class is:

-------------------------------------------------------------------------------------------------------------------------------
By the end of this session you will be able to :
  • understand how the FOR loop works to create factorial of a  number
  • Also understand how the FOR loop works to build up the sum of ODD numbers. (Accumulate values)
  • Acquire the skill to use FOR loop to find the sum of multiples of 5.
--------------------------------------------------------------------------------------------------------------------
TODAY, YOU WILL BE WRITING THE CODING FOR THE FOLLOWING QUESTIONS. i SHALL ASSIST YOU IN THE PROCESS.
Q1. Write a program in Python, to accept a number from the user and calculate the factorial of a number.

Example 4!=4X3X2X1



--------------------------------------------------------------------------------------------------------------------
Q2. Write a program in Python, to accept the upper limit from the user and calculate the sum of odd numbers from 1 to that  upper limit.

# program to find the sum of odd numbers
sum=0
upp_lt=int(input("Enter the upper limit:"))
for num in range(1,upp_lt+1,2)
      sum=sum+num
print("The sum of odd numbers between 1 and ",upp_lt,"=",sum)
---------------------------------------------------------------------------------------------------------------------
Q3. Write a program in Python, to accept the upper limit from the user and calculate the sum of multiples of 5 from 5 to that  upper limit.




---------------------------------------------------------------------------------------------------------------------


TRY ALL THE PROGRAMS SHARED ON THE BLOGS TO GAIN THOROUGH KNOWLEDGE OF THE CONCEPTS SHARED.
ALL THE BEST .
  STAY SAFE!!!!!.

Comments

Post a Comment

Popular posts from this blog

HOLIDAY HW