PROGRAM 1
Best of Two Test Average
Code
m1 = int(input("Enter marks of test 1: "))
m2 = int(input("Enter marks of test 2: "))
m3 = int(input("Enter marks of test 3: "))
marks = [m1, m2, m3]
[Link](min(marks))
average = sum(marks) / 2
print("Best two test average:", average)
Sample Input
70
85
90
Output
Best two test average: 87.5
PROGRAM 2
Palindrome Number
Code
num = input("Enter a number: ")
rev = num[::-1]
if num == rev:
print("Palindrome")
else:
print("Not Palindrome")
Sample Input
121
Output
Palindrome
PROGRAM 3
Fibonacci Sequence
Code
n = int(input("Enter number of terms: "))
a=0
b=1
for i in range(n):
print(a, end=" ")
c=a+b
a=b
b=c
Sample Input
5
Output
01123
PROGRAM 4
Count Words, Digits, Uppercase, Lowercase
Code
text = input("Enter a sentence: ")
words = len([Link]())
digits = 0
upper = 0
lower = 0
for ch in text:
if [Link]():
digits += 1
elif [Link]():
upper += 1
elif [Link]():
lower += 1
print("Words:", words)
print("Digits:", digits)
print("Uppercase:", upper)
print("Lowercase:", lower)
Sample Input
Hello123
Output
Words: 1
Digits: 3
Uppercase: 1
Lowercase: 4
PROGRAM 5
Binary to Decimal & Octal to Hexadecimal
Code
binary = input("Enter binary: ")
decimal = int(binary, 2)
print("Decimal:", decimal)
octal = input("Enter octal: ")
hexa = hex(int(octal, 8))
print("Hexadecimal:", hexa)
Sample Input
101
17
Output
Decimal: 5
Hexadecimal: 0xf
PROGRAM 6
String Similarity
Code
from difflib import SequenceMatcher
s1 = input("Enter string 1: ")
s2 = input("Enter string 2: ")
ratio = SequenceMatcher(None, s1, s2).ratio()
percent = ratio * 100
print("Similarity ratio:", ratio)
print("Similarity percentage:", percent, "%")
Sample Input
data
database
Output
Similarity ratio: 0.6666666666666666
Similarity percentage: 66.66666666666666 %
PROGRAM 7
Bar Plot
Code
import [Link] as plt
subjects = ["Python", "DBMS", "Maths"]
marks = [85, 78, 90]
[Link](subjects, marks)
[Link]("Subjects")
[Link]("Marks")
[Link]("Marks Bar Plot")
[Link]()
Output
(Bar graph displaying marks of subjects)
PROGRAM 8
Scatter Plot
Code
import [Link] as plt
x = [1, 2, 3, 4, 5]
y = [2, 4, 5, 4, 5]
[Link](x, y)
[Link]("X values")
[Link]("Y values")
[Link]("Scatter Plot Example")
[Link]()
Output
(Scatter graph showing plotted points)
PROGRAM 9
Histogram Plot
Code
import [Link] as plt
data = [12, 15, 14, 10, 18, 19, 20, 22, 21]
[Link](data)
[Link]("Value Range")
[Link]("Frequency")
[Link]("Histogram Example")
[Link]()
Output
(Histogram showing frequency distribution)
PROGRAM 10
Student Marks Histogram
Code
import [Link] as plt
marks = [35, 40, 56, 60, 60, 72, 75, 80, 85, 90, 95]
[Link](marks)
[Link]("Marks Range")
[Link]("No. of Students")
[Link]("Student Marks Histogram")
[Link]()
Output