Python Lab 5
Python Lab 5
#CN-23032
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::Labsession5:::::::::::::::::::::::::::::::::::
# question 1
i=2
x = int(input("Please enter any digit upto which prime numbers are reqd:"))
while i<=x:
if i == 2 or i == 3 or i == 5:
print(i)
if i % 2 and i % 3 and i % 5:
print(i)
i = i+1
x = int(input("Please enter any digit upto which prime numbers are reqd:"))
while i<=x:
if i == 2 or i == 3 or i == 5:
print(i)
if i % 2 and i % 3 and i % 5:
print(i)
i = i+1
# question 2
# Compute the following using FOR LOOP only :
positive= 0
negative= 0
print("Enter numbers of values to be checked")
n = int(input("Please enter any number to check:"))
for i in range (0,n+1):
x=float(input("Please enter any number"))
if x>0:
positive=positive+1
if x<0:
negative=negative+1
print("Total positive number entered:",positive)
print("Total negative number entered:",negative)
# question 6
#To calculate average and percentage marks, you have to ask user to enter marks obtain in 5 subjects
then calculate and print average and percentage marks.
#question 5
#write a o ton sum the square of multipls of 4 upto N.
n = int(input("Please enter any number: "))
summatin = 0
for i in range(0, n):
summatin=summatin+(i**2)
i = i+4
print("The sum of square of multiple of 4 till Nth term is:" , summatin)
#question 7
x=0
SFD = []
BMD = []
span = []