Python 66
Python 66
I wish to express my deep sense of gratitude and indebtedness to our teacher , ICT Teachers, Springdales School for
her invaluable help, advice and guidance in the preparation of the practical record book.
I am also greatly indebted to our Principal Dr.Brian, Vice Principal-Ms.Bushra Mansoor, Deputy, Coordinators and
school authorities for providing me with the facilities and requisite laboratory conditions for making this practical file.
I also extend my thanks to a number of teachers, my classmates and friends who helped me to complete this
practical file successfully.
CONTENTS:
1.To find average and grade for given marks.
2.To find sale price of an item with given cost and discount (%).
3.To calculate perimeter/circumference and area of shapes such as triangle, rectangle,
square and circle.
4.To calculate Simple and Compound interest.
5.To calculate profit-loss for given Cost and Sell Price.
6.To calculate EMI for Amount, Period and Interest.
7.To calculate tax - GST / Income Tax.
8.To find the largest and smallest numbers in a list.
9.To find the third largest/smallest number in a list.
10.To find the sum of squares of the first 100 natural numbers.
11.To print the first ‘n’ multiples of given number.
12.To count the number of vowels in user entered string.
13.To print the words starting with a alphabet in a user entered string.
14.To print number of occurrences of a given alphabet in each string.
15.Create a dictionary to store names of states and their capitals.
16.Create a dictionary of students to store names and marks obtained in 5 subjects.
17.To print the highest and lowest values in the dictionary.
18.To create a database
19.To create student table with the student id, class, section, gender, name, dob, and marks
as attributes where the student id is the primary key.
20.To insert the details of at least 10 students in the above table.
21.To display the entire content of table.
22.To display Rno, Name and Marks of those students who are scoring marks more than 50.
23.To display Rno, Name, DOB of those students who are born between ‘2005- 01-01’ and ‘2005-12-31’.
Programming in python
1.To find average and grade for given marks.
h= (a+b+c+d)/4
ifh >=90:
print ("A1"')
print ("A2")
print ("B1")
elif. h == 60:
print ("B2")
print ("C1")
print ("C2")
else:
print ("F")
2. To find sale price of an item with given cost and discount (%)
cost = float(input("Cost of the item: $"))
discount = float(input("Discount percentage: "))
3.To calculate perimeter/circumference and area of shapes such as triangle, rectangle, square and circle.
import math
# Triangle
a, b, c = 3, 4, 5
triangle_perimeter = a + b + c
s = (a + b + c) / 2
triangle_area = math.sqrt(s * (s - a) * (s - b) * (s - c))
# Rectangle
length, width = 6, 8
rectangle_perimeter = 2 * (length + width)
rectangle_area = length * width
# Square
side = 5
square_perimeter = 4 * side
square_area = side ** 2
# Circle
radius = 2.5
circle_circumference = 2 * math.pi * radius
circle_area = math.pi * radius ** 2
# Output results
print("Triangle Perimeter:", triangle_perimeter)
print("Triangle Area:", triangle_area)
print("Rectangle Perimeter:", rectangle_perimeter)
print("Rectangle Area:", rectangle_area)
print("Square Perimeter:", square_perimeter)
print("Square Area:", square_area)
print("Circle Circumference:", circle_circumference)
print("Circle Area:", circle_area)
4.To calculate Simple and Compound interest.
principal_amount = 1000
interest_rate = 5
time_period = 2
compound_frequency = 1
# Input values
cost_price = 800
sell_price = 1000
GST calculation:
largest_number = max(numbers)
smallest_number = min(numbers)
third_largest = numbers[-3]
third_smallest = numbers[2]
10.To find the sum of squares of the first 100 natural numbers.
print("The sum of squares of the first 100 natural numbers is:", sum_of_squares)
13.To print the words starting with a alphabet in a user entered string.
state_capitals = {
"Alabama": "Montgomery",
"Alaska": "Juneau",
"Arizona": "Phoenix",
"Arkansas": "Little Rock",
"California": "Sacramento",}
students_marks = {
"John": [85, 90, 92, 88, 89],
"Alice": [78, 87, 80, 92, 85],
"Bob": [95, 88, 94, 90, 91],
}
print("Marks of John:", students_marks["John"])
19. To create student table with the student id, class, section, gender, name, dob, and marks as attributes where the
student id is the primary key.
22.To display Rno, Name and Marks of those students who are scoring marks more than 50.