draculla
draculla
draculla
PROGRAM: - Python program to find average and grade for given marks
SOURCE CODE:-
output:
PRACTICAL NO:-2
PROGRAM:- To find the sale price of an item with given cost and discount (%)
SOURCE CODE:-
output:
PRACTICAL NO:- 3
SOURCE CODE:-
import math
side=float(input("Enter the side of square:"))
ar_sq=float(side*side)
print("Area of Square:",ar_sq)
peri=float(4*side);
print("Perimeter of square is:",peri)
print()
r=float(input("enter the radius of circle:"))
ar_ci=float(3.14*r*r)
print("Area of circile:",ar_ci)
per_ci=float(2*3.14*r);
print("Perimter of circle is:%.2f"%per_ci)
print()
l=float(input("enter the length of rectangle:"))
b=float(input("enter the breadth of rectangle:"))
ar_rect=float(l*b)
print("Area of rectangle is:",ar_rect)
per_rect=float(2*(l+b))
print("Area of rectangle is:",per_rect)
print()
ba=float(input("enter the base of right angled triangle:"))
h=float(input("enter the height of right angled triangle:"))
ar_tri=float(float((ba*h)/2))
print("Area of triangle is:",ar_tri)
hpt=float(math.sqrt(h*h+ba*ba))
peri_tri=float(h+ba+hpt)
print("Perimter of right angled triangle is:",peri_tri)
output:
PRACTICAL NO:- 4
output:
PRACTICAL NO:- 5
SOURCE CODE:-
output:
PRACTICAL NO:- 6
output:
PRACTICAL NO:- 7
output:
PRACTICAL NO:- 8
number=[34,12,5,67,1]
largest=max(number)
smallest=min(number)
print("largest",largest)
print("smallest",smallest)
output:
PRACTICAL NO:- 9
Source code:-
l = []
n = int(input("Enter the Number of List Elements: "))
for i in range(1, n + 1):
ele = int(input("Please enter the Value of Element%d : " %i))
l.append(ele)
large = l[0]
sec_large = l[0]
third_large = l[0]
for i in l :
if i > large:
third_large = sec_large
sec_large = large
large = i
elif i > sec_large :
third_large = sec_large
sec_large = i
elif i > third_large:
third_large = i
print("Third largest number of the list is:",third_large)
output:-
PRACTICAL NO:- 10
Source code:-
sum1 = 0
for i in range(1, 101):
sum1 = sum1 + (i*i)
print("Sum of squares is : ", sum1)
output:-
PRACTICAL NO:- 11
Source code:-
number=[34,12,5,67,1]
largest=max(number)
smallest=min(number)
print("largest",largest)
print("smallest",smallest)
output:-
PRACTICAL NO:- 12
Source code:-
txt=input("Enter a word:")
vowels=0
for i in txt:
if(i=='a' or i=='e' or i=='i' or i=='o' or \
i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or
i=='U'):
vowels=vowels+1
print("Number of vowels are:",vowels)
output:-
PRACTICAL NO:- 13
PROGRAM:- to print the word starting with a particular alphabet in a user enter string
Source code:-
txt=input("Enter the text:")
al=input("Enter alphabet to print the words:")
for i in txt.split():
if i.startswith(al):
print(i)
output:-
PRACTICAL NO:-14
Source code:-
count_occurrences(string, char):
return string.count(char)
input_string = input("Enter the string: ")
input_char = input("Enter the character to count: ")
if len(input_char) != 1:
print("Please enter a single character for counting.")
else:
occurrences = count_occurrences(input_string, input_char)
print(f"The character '{input_char}' occurs {occurrences} times in the string.")
output:-
PRACTICAL NO:- 15
Source code:-
states_and_capitals = { 'Andhra Pradesh': 'Amaravati', 'Tamil Nadu': 'Chennai', 'Karnataka': 'Bengaluru', 'Maharashtra'
'Bihar': 'Patna','Punjab': 'Chandigarh', 'Gujarat': 'Gandhinagar','Kerala': 'Thiruvananthapuram','Haryana': 'Chandigarh',
'Himachal Pradesh': 'Shimla', 'Uttarakhand': 'Dehradun', 'Assam': 'Dispur', 'Chhattisgarh': 'Raipur', 'Jharkhand': 'Ranchi',}
def search_capital(state_name):
if state_name in states_and_capitals:
return states_and_capitals[state_name]
else:
state_to_search = input("Enter the name of the state to search for its capital:")
capital = search_capital(state_to_search)
output:-
PRACTICAL NO:-16
Source code:-
students_marks = { 'rohan patel': [85, 90, 78, 92, 88], 'rishi obroy': [76, 82, 91, 89, 84], 'anant
ambani': [88, 76, 95, 80, 90], 'sharuk khan': [92, 89, 84, 77, 93], 'akshay kumar': [70, 85, 88, 93, 80]}
def print_marks(student_name):
if student_name in students_marks:
marks = students_marks[student_name]
print(f"Marks of {student_name}: {marks}")
else:
print(f"Student '{student_name}' not found.")
def average_marks(student_name):
if student_name in students_marks:
marks = students_marks[student_name]
average = sum(marks) / len(marks)
print(f"The average marks of {student_name} are: {average:.2f}")
else:
print(f"Student '{student_name}' not found.")
def highest_scorer():
highest_marks = -1
top_student = ""
for student, marks in students_marks.items():
total_marks = sum(marks)
if total_marks > highest_marks:
highest_marks = total_marks
top_student = student
print(f"The highest scorer is {top_student} with total marks: {highest_marks}")
print_marks('rohan patel')
average_marks('sharuk khan')
highest_scorer()
output:-
PRACTICAL NO:-17
Source code:-
my_dict = {'a': 10, 'b': 20, 'c': 5, 'd': 15}
max_key = max(my_dict, key=my_dict.get)
max_value = my_dict[max_key]
min_key = min(my_dict, key=my_dict.get)
min_value = my_dict[min_key]
print(f"Highest value: {max_value} (Key: '{max_key}')")
print(f"Lowest value: {min_value} (Key: '{min_key}')")
output:-
PM SHRI
Jawahar Navodaya Vidyalaya
cost=float(input("Ent
er the