0% found this document useful (0 votes)
1 views2 pages

Python Looping Programs Notes

The document provides Python programs for various looping tasks including generating Fibonacci terms, checking for even numbers, determining if a number is prime, calculating factorials, and printing multiplication tables. Each program includes sample input and output to demonstrate functionality. The examples cover a range of mathematical concepts and basic programming techniques.

Uploaded by

hemantpaspunur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views2 pages

Python Looping Programs Notes

The document provides Python programs for various looping tasks including generating Fibonacci terms, checking for even numbers, determining if a number is prime, calculating factorials, and printing multiplication tables. Each program includes sample input and output to demonstrate functionality. The examples cover a range of mathematical concepts and basic programming techniques.

Uploaded by

hemantpaspunur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Looping Programs with Sample Output

Q1 Fibonacci Terms
n=int(input("Enter number of terms: "))
a,b=0,1
for i in range(n):
print(a,end=" ")
a,b=b,a+b
Sample Output:
Input:7
Output: 0 1 1 2 3 5 8

Q2 Even Numbers
start=int(input())
end=int(input())
for i in range(start,end+1):
if i%2==0: print(i,end=" ")
Sample Output:
Input:10,20
Output:10 12 14 16 18 20

Q3 Prime Check
num=int(input())
if num>1:
for i in range(2,num):
if num%i==0:
print("Not Prime")
break
else:
print("Prime")
Sample Output:
Input:13
Output:Prime

Q4 Prime 1-100
for num in range(2,101): ...
Sample Output:
Output: 2 3 5 ... 97

Q5 Factorial
num=int(input())
fact=1
for i in range(1,num+1): fact*=i
print(fact)
Sample Output:
Input:5
Output:120
Q6 Fibonacci Sequence
a,b=0,1
for i in range(10): print(a,end=' '); a,b=b,a+b
Sample Output:
Output:0 1 1 2 3 5 8 13 21 34

Q7 Armstrong
num=int(input())
...
Sample Output:
Input:153
Output:Armstrong Number

Q8 Multiplication Table
num=int(input())
for i in range(1,11): print(num,'x',i,'=',num*i)
Sample Output:
Input:5
Output:5 x 1 = 5 ... 5 x 10 = 50

You might also like