0% found this document useful (0 votes)
2 views

Class 8_ Python Programs

The document contains a series of Python programming exercises, including printing a multiplication table, generating a Fibonacci series, and printing numbers in reverse order. It also includes tasks for calculating multiples of 5, summing a range of numbers, and printing even numbers, along with a pattern printing exercise. Each exercise is accompanied by example code demonstrating the required functionality.

Uploaded by

devilxd131
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Class 8_ Python Programs

The document contains a series of Python programming exercises, including printing a multiplication table, generating a Fibonacci series, and printing numbers in reverse order. It also includes tasks for calculating multiples of 5, summing a range of numbers, and printing even numbers, along with a pattern printing exercise. Each exercise is accompanied by example code demonstrating the required functionality.

Uploaded by

devilxd131
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Python

1. Write a program to print table of 5 using range() function.


for I in range(5, 51, 5):
print (I)

2. Write a program to print all the numbers in backward order from 20 to 10.
for I in range(20, 10, -1):
print(I)

3. To print the Fibonacci series starting from 1 up to number entered by user.


n=int(input(“Enter last number of series”))
x=0
y=0
z=1
while z<=n:
print(z)
x= y
y=z
z=x+y

4. Print table of a number entered by user using while and for loop both.
#Using While loop
n = int(input(“Enter a number”))
i =1
while i<=10:
print(n, “*” , i , “=” , n*i)
i =i+1

#Using for loop


n = int(input(“Enter a number”))
for i in range (1,11):
print(n, “*” , i , “=” , n*i)

5. To print all the multiples of 5 between a given range of numbers entered by the
user.

a = int(input(“Enter starting range of the number”))


b = int(input(“Enter ending range of the number”))

for I in range(a, b+1):

if i%5 == 0:

print(i)

6. To print sum of all the positive and negative numbers that lies between -10 to 15.
sum=0
for i in range (-10, 16):
sum =sum+i
i=i+1
print(sum)

7. Write a program using for loop to print all the even numbers starting from 2 to x,
where x is entered by the user
x = int(input(“Enter a number”))
for i in range(2, x+1):
if (n%2 ==0):
print(n)
8. Print the following pattern using looping in python.

*
**
***
****
*****
Code:
for i in range (1,6,1):
for j in range (1,I+1,1):
print(“*”, end= “ ”)
print()

You might also like