Update Notes 2024-25
Update Notes 2024-25
Programming-
selection
3.Write a program that takes a number and checks if the given number is greater than
100.(donot give else condition)
num=int(input("Enter any no:"))
if num>100:
print(num,“ is greater then 100")
4.Write a program that takes a number and checks whether the given number is odd or
even.
num=int(input("Enter any no:"))
if num%2==0:
print("Even no")
else:
print("Odd no")
5.Write a program to input a number and check whether the entered no is positive,
negative or zero.
num=int(input("Enter any no:"))
if num>0:
print(num,"is positive no")
elif num<0:
print(num,"is negative no")
else:
print("No is zero")
6.Write a program to accept three number and print the maximum(largest) of the three.
a=int(input(“Enter first no:”))
b=int(input(“Enter second no:”))
c=int(input(“Enter third no:”))
max=a
if b>max:
max=b
if c>max:
max=c:
print(“Maximum no=“, max)
7.Write a program to calculate and display area of circle and triangle.
print(“1.Area of circle”)
print(“2.Area of triangle”)
choice=int(input(“Enter your choice:”))
if choice==1:
r=float(input(“Enter radius:”))
print(3.14*r*r)
else:
b=float(input(“Enter base:”))
h=float(input(“Enter height:”))
print(0.5*b*h)
8. Write a program to input a character and check whether a given character is an
uppercase or a lowercase or a digit or any other character.
ch=input("Enter any character:")
if ch>='A' and ch<='Z':
print("Its an Uppercase character")
elif ch>='a' and ch<='z':
print("Its an Lowercase character")
elif ch>='0' and ch<='9':
print("Its a digit")
else:
print("Any other character")
9.Write a program to input two numbers and an arithmetic operator and display the
computed result.(make four function calculator.)
a=float(input("Enter first no:"))
b=float(input("Enter second no:"))
op=input("Enter an operator(+,-, /, *):")
if op=='+':
print(a+b)
elif op=='-':
print(a-b)
elif op=='/':
print(a/b)
elif op=='*':
print(a*b)
else:
print("Wrong operator entered")
10.Write a program to read day of week in number and display its name on the screen.
dow=int(input(‘Enter day of week in no:’))
if dow==1:
print(‘Sunday’)
elif dow==2
print(‘Monday’)
elif dow==3:
print(‘Tuesday’)
elif dow==4:
print(‘Wednesday’)
elif dow==5:
print(‘Thursday’)
elif dow==6:
print(‘Friday’)
elif dow==7:
print(‘Saturday’)
11.Write a program to find the grade of a student when grades are allocated as given in the
table
given below:
Percentage of Marks Grade
Above 90% A
81% to 90% B
71% to 80% C
61% to 70% D
Below & equal to 60% E
perc=float(input(“Enter percentage marks:”))
if perc >90:
grade=‘A’
elif perc>80 and perc<=90:
grade=’B’
elif perc>70 and perc<=80:
grade=’C’
elif perc>60 and perc<=70:
grade=’D’
elif perc<=60:
grade=’E’
print(“For percentage”, perc , ”Grade is “,grade)
Loops
12.Write a program to print first five even nos.
for i in range(2,11, 2):
print(i, end=’ ‘)
13.Write a program to print first five odd nos.
for i in range(1,11, 2):
print(i, end=’ ‘)
14. Write a program that inputs a number and prints its multiplication table
n=int(input(‘Enter any no:’))
for i in range(1,11):
print(n,”x”, i, “=”, n*i )
15. Write a program to input a number n and print its factorial.
n=int(input(‘Enter any no:’))
fact=1
for i in range(1, n+1):
fact=fact*i
print(fact)
16. Write a Python program that inputs n numbers using a for loop and prints whether
each number is even or odd.
n=int(input('How many no you want to enter’))
for i in range(1, n+1):
num=int(input(‘Enter a no:’))
if num%2==0:
print(num,”is even no.”))
else:
print(num,”is odd no.”))
17.Write a program to find sum of n natural numbers.
n=int(input(input(‘How many nos you want to add?’))
sum=0
for i in range(1, n+1):
sum=sum+i
print(‘Sum=’,sum)
18.Write a program to generate a fibonacii series of n number of terms.
0 1 1 2 3 5 8………………………. n terms
n=int(input("Enter no of terms you want to generate:"))
f,s=0,1
print(f,s,end=' ')
for i in range(3,n+1):
t=f+s
print(t,end=' ')
f=s
s=t
19 .Write a program to find sum of series given below:
1+4+9+16+………+n2
n=int(input(“How many terms you want to add?”))
sum=0
for i in range(1,n+1):
sum=sum+i*i
print(sum)
20. Write a program to find sum of series given below:
2+4+6+8+………+2n
n=int(input(“How many terms you want to add?”))
sum=0
for i in range(1, (2*n)+1, 2):
sum=sum+i
print(sum)
21.Write a program to find sum of series given below:
1+3+5+7+………+2n-1
n=int(input(“How many terms you want to add?”))
sum=0
for i in range(1, (2*n-1)+1, 2):
sum=sum+i
print(sum)
22.Write a program to find sum of series given below:
x/1+x/2+x/3+x/4+………+x/n
n=int(input(“How many terms you want to add?”))
x=int(input(“Enter value of x:”))
sum=0
for i in range(1, n+1):
sum=sum+x/i
print(sum)
23.Write a program to find sum of series given below:
x/2+x/4+x/6+………+x/2n
n=int(input(“How many terms you want to add?”))
x=int(input(“Enter value of x:”))
sum=0
for i in range(1, (2*n)+1, 2):
sum=sum+x/i
print(sum)
24 .Write a program to find sum of series given below:
x/1+x/3+x/5+………+x/2n-1
n=int(input(“How many terms you want to add?”))
x=int(input(“Enter value of x:”))
sum=0
for i in range(1, (2*n-1)+1, 2):
sum=sum+x/i
print(sum)
25.Write a program to find sum of series given below:
x1/1+x2/2+x3/3+x4/4+………+xn/n
n=int(input(“How many terms you want to add?”))
x=int(input(“Enter value of x:”))
sum=0
p=1
for i in range(1, n+1):
sum=sum+x**p/i
p=p+1
print(sum)
26.Write a program to find sum of series given below:
X0/1+x1/2+x2/3+x3/4+………+xn-1/n
n=int(input(“How many terms you want to add?”))
x=int(input(“Enter value of x:”))
sum=0
p=0
for i in range(1, n+1):
sum=sum+x**p/i
p=p+1
print(sum)
27.Write a program to find sum of series given below:
x1/1+x2/3+x3/5+x4/7+………+xn/2n-1
n=int(input(“How many terms you want to add?”))
x=int(input(“Enter value of x:”))
sum=0
p=1
for i in range(1, (2* n-1)+1, 2):
sum=sum+x**p/i
p=p+1
print(sum)
28.Write a program to find sum of series given below:
x1/1+x3/2+x5/3+x7/4+………+x2n-1/n
n=int(input(“How many terms you want to add?”))
x=int(input(“Enter value of x:”))
sum=0
p=1
for i in range(1, n+1):
sum=sum+x**p/i
p=p+2
print(sum)
Nested Loops