List of Programs done in class(in script mode)
Sequential Programs:-
1) To show calculations by all the arithmetic operators taking 2
numbers as input.
a= int(input("Enter 1st number: "))
b= int(input("Enter 2nd number: "))
sum = a+b
dif = a-b
prod = a*b
div = a/b
floor_div = a//b
rem = a%b
power = a**b
print("Sum of a and b is:", sum)
print("Difference of a and b is:", dif)
print("Product of a and b is:", prod)
print("Division of a and b is:", div)
print("Floor Division of a and b is:", floor_div)
print("Remainder of a and b is:", rem)
print("Power of b to a is:", power)
2) To show the use of separators with String variables.
Fname = input("Enter your First Name : ")
Lname = input("Enter your Last Name : ")
print (“With comma Seperator : ”, Fname,Lname)
print (“With tab space Seperator : ”, Fname, "\t", Lname)
print (“With new line Seperator : ”, Fname, "\n", Lname)
3) To show the use of string operators (Concatenation & Repetitive)
Fname = input("Enter your First Name : ")
Lname = input("Enter your Last Name : ")
print (“As concatenation : “, Fname + Lname)
print (“As Repetative operator ; “, Fname *5)
4) To calculate area and perimeter of rectangle taking length and
breadth as input.
L=int(input("Enter the Length of rectangle= "))
B=int(input("Enter the Breadth of rectangle= "))
print("Area of the rectangle is= ",L*B)
print("Perimeter of the rectangle is= ",2*(L+B))
5) To calculate area and perimeter of square taking side as input.
s=int(input("Enter the value of side= "))
print("Area of the square is= ",s*s)
print("Perimeter of the square is= ",4*s)
6) To calculate area and circumference of circle taking radius as input.
a=int(input("enter the radius:"))
print("the area of the circle is:",3.14*a*a)
print("the circumference of the circle is:",2*3.14*a)
7) To take input Name, Roll and marks of 5 subjects to calculate and
display Total Marks and Percentage.
roll = input("Enter your Roll No. :")
name = input("Enter your name: " )
M = int(input("Enter marks for Maths: "))
Sc = int(input("Enter marks for Science: "))
H = int(input("Enter marks for Hindi: "))
E = int(input("Enter marks for Englishe: "))
B = int(input("Enter marks for Bengali: "))
Total = M + Sc + H + E + B
print("Total Marks achieved is : ", Total)
per = (Total/500) * 100
print("Percentage achieved is : ", per, "%")
8) To swap the values of two variables.
Conditional Programs:-
1) To check if the number is equal to 200, less than 200 or not.
a= int(input("Enter a number: "))
if (a ==200):
print("The number is Equal to 200")
elif (a<200):
print("The number is lesser than 200")
else:
print("The number is greater than 200")
2) To check if the number is positive, negative or equal to zero.
num = int (input("Enter the value ="))
if (num > 0):
print("Number is positive")
elif (num == 0):
print("Number is equal to 0")
else:
print("Number is negative")
3) To check if the number is even or odd.
num = int(input("Enter a number: "))
if (num % 2 == 0):
print("The number is Even")
else:
print("The number is Odd")
4) To check if the number is single digit, double digit or more than
that.
num = int (input("Enter the value ="))
if (num > 0 and num <= 9):
print("Number is single digit")
elif (num > 9 and num <=99):
print("Number is double digit")
else:
print("Number is more than 2 digits")
5) To check if you are eligible to vote or not.
age = int(input("Enter your age = "))
if (age >= 18):
print("You are Eligible to Vote")
else:
print ("You are not Eligible to Vote")
6) To display days of week based on the number input.
a = int(input("Enter a number between 1 - 7 : "))
if (a == 1):
print ("Today is Monday")
elif (a == 2):
print ("Today is Tuesday")
elif (a == 3):
print ("Today is Wednesday")
elif (a == 4):
print ("Today is Thursday")
elif (a == 5):
print ("Today is Friday")
elif (a == 6):
print ("Today is Saturday")
elif (a == 7):
print ("Today is Sunday")
else:
print("Areh !!! Budhdhu...there are only 7 days in a Week ")
7) To check if a letter is a vowel or a consonant.
a = input("Enter a character : ")
if (a == 'a' or a =='A'):
print ("It's a Vowel")
elif (a == 'e' or a =='E'):
print ("It's a Vowel")
elif (a == 'i' or a =='I'):
print ("It's a Vowel")
elif (a == 'o' or a =='O'):
print ("It's a Vowel")
elif (a == 'u' or a =='U'):
print ("It's a Vowel")
else:
print("It's a Consonant")
8) To find greatest among 3 numbers taken as input.
a = int (input("Enter the 1st value = "))
b = int (input("Enter the 2nd value = "))
c = int (input("Enter the 3rd value = "))
if (a > b and a> c):
print("The number”, a, “is greatest”")
elif (b > a and b> c):
print("The number”, b, “is greatest”")
else:
print("The number”, c, “is greatest”")