draculla

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

PRACTICAL NO:-1

PROGRAM: - Python program to find average and grade for given marks
SOURCE CODE:-

mm=int(input("enter maximum marks:"))


eng=int(input("enter marks of english:"))
ip=int(input("enter marks of ip:"))
bio=int(input("enter mark of biology:"))
chem=int(input("marks of chemistry:"))
tot=eng+ip+bio+chem
t_mm=mm*4
per=(tot/t_mm)*100
print("Average is:",per,"%")
if per>=91 and per<=100:
gr='A1'
elif per>=81 and per<=90:
gr='A2'
elif per>=71 and per<=80:
gr='B1'
elif per>=61 and per<=70:
gr='B2'
else:
gr="invalid grade"
print("the grade is:",gr)

output:
PRACTICAL NO:-2

PROGRAM:- To find the sale price of an item with given cost and discount (%)
SOURCE CODE:-

cost=float(input("Enter the cost : "))


dis_per=float(input("Enter the discount in % : "))
dis=cost*dis_per/100
sale_price=cost-dis
print("Cost Price : ",cost)
print("Discount: ",dis)
print("Selling Price : ",sale_price)

output:
PRACTICAL NO:- 3

PROGRAM:- To calculate perimeter,circumference and area of shape such as


triangle,rectangle,square and circle

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

PROGRAM:- to calculate simple and compound interest


SOURCE CODE:-

p = float(input('Enter the principal amount: '))


r = float(input('Enter the rate of interest: '))
t = float(input('Enter the time duration: '))
si = (p*r*t)/100
ci= p * ( (1+r/100)**t - 1)
print('Simple interest is: %.2f' % (si))
print('Compound interest is: %.2f' %(ci))

output:
PRACTICAL NO:- 5

PROGRAM:- to calculate profit-loss for given cost and sell price

SOURCE CODE:-

cost = float(input("Enter the cost of the product: "))


sale_amt = float(input("Enter the Sales Amount: "))
if(cost > sale_amt):
amt = cost - sale_amt
print("Total Loss Amount = ",amt)
elif(cost < sale_amt):
amt = sale_amt - cost
print("Total Profit =",amt)
else:
print("No Profit No Loss!!!")

output:
PRACTICAL NO:- 6

PROGRAM:- to calculate EMI for amount period and intrest


SOURCE CODE:-

p = float(input("Enter the principal:"))


r = float(input("Enter the rate of interest:"))
t = float(input("Enter the time:"))
r = r / (12 * 100)
t = t * 12
emi = (p * r * pow(1 + r, t)) / (pow(1 + r, t) - 1)
print("Monthly EMI is= %.2f"%emi)

output:
PRACTICAL NO:- 7

PROGRAM:- to calculate TAX-GST/INCOME TAX


SOURCE CODE:-

op=float(input("Enter original Price:-"))


np = float(input("Enter Net Price:-"))
GST_amt = np - op
GST_per = ((GST_amt * 100) / op)
print("GST Rate = %.2f"%GST_per,"%")
print("GST Amount = ",GST_amt)

output:
PRACTICAL NO:- 8

PROGRAM:- to find largest and smallest number in list


SOURCE CODE:-

number=[34,12,5,67,1]

largest=max(number)

smallest=min(number)

print("largest",largest)

print("smallest",smallest)

output:
PRACTICAL NO:- 9

PROGRAM:- to find third largest/smallest number in list

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

PROGRAM:- to find sum of squares of the first 100 natural numbers

Source code:-

sum1 = 0
for i in range(1, 101):
sum1 = sum1 + (i*i)
print("Sum of squares is : ", sum1)

output:-

PRACTICAL NO:- 11

PROGRAM:- to find first ‘n’ multiples of given number

Source code:-

number=[34,12,5,67,1]
largest=max(number)
smallest=min(number)
print("largest",largest)
print("smallest",smallest)

output:-
PRACTICAL NO:- 12

PROGRAM:- to count the vowels in user entered string

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

PROGRAM:- to print number of occurrence of a given alphabet in a given string

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

PROGRAM:- create a dictionary to store names of state and thier capital

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:

return "State not found in the dictionary."

state_to_search = input("Enter the name of the state to search for its capital:")

capital = search_capital(state_to_search)

print(f"The capital of {state_to_search} is: {capital}")

output:-
PRACTICAL NO:-16

PROGRAM:- create a dictionary of students to store names and marks


obtained in 5 subjects

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

PROGRAM:- to print highest and lowest values in the dictionary

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

Name:- Divya Parmar


Class:- 11th A
Subject:-Information Practices
Guided by :- Shivani Soni

cost=float(input("Ent
er the

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy