0% found this document useful (0 votes)
17 views

Python 66

The document outlines a programming practical file containing Python programs to perform various calculations. It includes programs to calculate averages, discounts, areas and perimeters of shapes, interests, taxes, and more. It also includes SQL commands to create a student database with tables to insert student records.

Uploaded by

sahilmadathil24
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Python 66

The document outlines a programming practical file containing Python programs to perform various calculations. It includes programs to calculate averages, discounts, areas and perimeters of shapes, interests, taxes, and more. It also includes SQL commands to create a student database with tables to insert student records.

Uploaded by

sahilmadathil24
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

CBSE Informatics Practices

Program Report File


2023-2024
Name- Sahil Muhammed Madathil
Grade- 11E
Subject-Informatics Practices
Code- 065
Acknowledgment

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.

a= int(input("Enter English marks = "))

b= int(input"Enter Maths marks = "))

c= int(input("Enter Science marks = "))

d= int(input("Enter Social studies marks = ")

h= (a+b+c+d)/4

print ("Average marks =", h)

ifh >=90:

print ("A1"')

elif h >= 80:

print ("A2")

elif. h >= 70:

print ("B1")

elif. h == 60:

print ("B2")

elif. h >= 50:

print ("C1")

elif h >= 40:

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: "))

sale_price = cost - cost * (discount / 100)

print(f"Sale price after a {discount}% discount: ${sale_price:.2f}")

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

simple_interest = (principal_amount * interest_rate * time_period) / 100

compound_frequency = 1

amount = principal_amount * (1 + interest_rate / (100 * compound_frequency)) ** (compound_frequency * time_period)


compound_interest = amount - principal_amount

print("Simple Interest:", simple_interest)


print("Compound Interest:", compound_interest)
5. To calculate profit-loss for given Cost and Sell Price.

# Input values
cost_price = 800
sell_price = 1000

# Calculate profit or loss


profit_loss = sell_price - cost_price

# Determine if it's a profit or loss


if profit_loss > 0:
print("Profit:", profit_loss)
elif profit_loss < 0:
print("Loss:", abs(profit_loss))
else:
print("No Profit, No Loss")

6.To calculate EMI for Amount, Period and Interest.

loan_amount = float(input("Enter the loan amount: "))


loan_period = int(input("Enter the loan period in months: "))
annual_interest_rate = float(input("Enter the annual interest rate: "))

monthly_interest_rate = (annual_interest_rate / 100) / 12

emi_amount = (loan_amount * monthly_interest_rate) / (1 - (1 + monthly_interest_rate)**-loan_period)

print(f"\nThe Equated Monthly Installment (EMI) is: {emi_amount:.2f}")


7. To calculate tax - GST / Income Tax.

GST calculation:

product_price = float(input("Enter the product price: "))

# (assuming 18% for this example)


gst_rate = 18 / 100

gst_amount = product_price * gst_rate

print(f"\nThe GST amount is: {gst_amount:.2f}")

8.To find the largest and smallest numbers in a list.

numbers = [float(x) for x in input("Enter a list of numbers separated by space: ").split()]

largest_number = max(numbers)
smallest_number = min(numbers)

print(f"Largest number: {largest_number}")


print(f"Smallest number: {smallest_number}")

9.To find the third largest/smallest number in a list.


input_numbers = input("Enter a list of numbers separated by space: ")
numbers = [float(num) for num in input_numbers.split()]
if len(numbers) < 3:
print("Please enter at least three numbers.")
else:
numbers.sort()

third_largest = numbers[-3]
third_smallest = numbers[2]

print(f"The third largest number is: {third_largest}")


print(f"The third smallest number is: {third_smallest}")

10.To find the sum of squares of the first 100 natural numbers.

sum_of_squares = sum(i**2 for i in range(1, 101))

print("The sum of squares of the first 100 natural numbers is:", sum_of_squares)

11.To print the first 'n' multiples of given number.

base_number = int(input("Enter a number to get multiples: "))


num_of_multiples = int(input("How many multiples do you want? "))
multiples = [base_number * i for i in range(1, num_of_multiples + 1)]

print(f"The first {num_of_multiples} multiples of {base_number} are: {multiples}")

12. To count the number of vowels in user entered string.

user_input = input("Enter a string: ")

vowel_count = sum(1 for char in user_input if char.lower() in 'aeiou')

print(f"The number of vowels in the entered string is: {vowel_count}")

13.To print the words starting with a alphabet in a user entered string.

user_input = input("Enter a string: ")

words_starting_with_a = [word for word in user_input.split() if word.lower().startswith('a')]

print(f"Words starting with 'a': {', '.join(words_starting_with_a)}")


14.To print number of occurrences of a given alphabet in each string.

strings = input("Enter strings (comma-separated): ").split(',')


alphabet_to_count = input("Enter alphabet to count: ")

for string in strings:


count = string.lower().count(alphabet_to_count.lower())
print(f"'{alphabet_to_count}' in '{string}': {count}")

15. Create a dictionary to store names of states and their capitals.

state_capitals = {
"Alabama": "Montgomery",
"Alaska": "Juneau",
"Arizona": "Phoenix",
"Arkansas": "Little Rock",
"California": "Sacramento",}

print("Capital of Arizona:", state_capitals["Arizona"])

state_capitals["New York"] = "Albany"

print("\nState Capitals Dictionary:", state_capitals)


16.Create a dictionary of students to store names and marks obtained in 5 subjects.

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"])

students_marks["Eve"] = [92, 94, 89, 88, 95]

print("\nStudents Marks Dictionary:", students_marks)

17.To print the highest and lowest values in the dictionary.


students_marks = {
"John": [85, 90, 92, 88, 89],
"Alice": [78, 87, 80, 92, 85],
"Bob": [95, 88, 94, 90, 91],
}

highest_student = max(students_marks, key=lambda student: sum(students_marks[student]) / len(students_marks[student]))


lowest_student = min(students_marks, key=lambda student: sum(students_marks[student]) / len(students_marks[student]))

print(f"Highest Average Marks: {highest_student} -


{sum(students_marks[highest_student])/len(students_marks[highest_student]):.2f}")
print(f"Lowest Average Marks: {lowest_student} -
{sum(students_marks[lowest_student])/len(students_marks[lowest_student]):.2f}")
SQL COMMANDS

18.To create a database


CREATE DATABASE your_database_name;
USE your_database_name;
CREATE TABLE your_table_name (
id INT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
age INT
);

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.

CREATE TABLE student (


student_id INT PRIMARY KEY,
class VARCHAR(10) NOT NULL,
section VARCHAR(1) NOT NULL,
gender VARCHAR(10) NOT NULL,
name VARCHAR(255) NOT NULL,
dob DATE NOT NULL,
marks INT
);

20. To insert the details of at least 10 students in the above table.

INSERT INTO student VALUES


(1, '10A', 'A', 'Male', 'John Doe', '2005-05-15', 85),
(2, '10A', 'B', 'Female', 'Alice Smith', '2006-02-28', 78),
-- More cool students below
(3, '10B', 'A', 'Male', 'Bob Johnson', '2005-09-10', 92),
(4, '10B', 'B', 'Female', 'Eve Williams', '2006-07-03', 94),
(5, '10C', 'A', 'Male', 'Charlie Brown', '2005-12-20', 88),
(6, '10C', 'B', 'Female', 'Grace Davis', '2006-10-15', 90),
(7, '10D', 'A', 'Male', 'Samuel Wilson', '2005-04-05', 91),
(8, '10D', 'B', 'Female', 'Sophia Miller', '2006-08-12', 87),
(9, '10E', 'A', 'Male', 'Daniel Lee', '2005-11-25', 89),
(10, '10E', 'B', 'Female', 'Olivia Brown', '2006-06-18', 93);

10.To display the entire content of table.

SELECT * FROM student;

22.To display Rno, Name and Marks of those students who are scoring marks more than 50.

SELECT Rno, Name, Marks


FROM student
WHERE Marks > 50;

You might also like