# Practical File Class 11 IP Term 1

## Program 1. To find average and grade for given marks.

```sub1=int(input("Enter marks of the first subject: "))

sub2=int(input("Enter marks of the second subject: "))

sub3=int(input("Enter marks of the third subject: "))

sub4=int(input("Enter marks of the fourth subject: "))

sub5=int(input("Enter marks of the fifth subject: "))

avg=(sub1+sub2+sub3+sub4+sub5)/5

#printing average
print ("The average marks",avg)

if(avg>=90):

elif(avg>=80 and avg<90):

elif(avg>=70 and avg<80):

elif(avg>=60 and avg<70):

else:

```

Output:

```Enter marks of the first subject: 45
Enter marks of the second subject: 78
Enter marks of the third subject: 87
Enter marks of the fourth subject: 95
Enter marks of the fifth subject: 99
The average marks 80.8
>>>```

## Program 2. To find the sale price of an item with a given cost and discount (%).

```cost_price=float(input("Enter Price : "))

discount_In_Percentage=float(input("Enter discount % : "))

discount=cost_price*discount_In_Percentage/100

saleing_price=cost_price-discount

print("Cost Price : ",cost_price)

print("Discount: ",discount)

print("Selling Price : ",saleing_price)
```

Output:

```Enter Price : 560
Enter discount % : 10
Cost Price : 560.0
Discount: 56.0
Selling Price : 504.0
>>>```

## Program 3. To calculate perimeter/circumference and area of shapes such as triangle, rectangle, square and circle.

```#We will make use of user defined python functions for this task.
#we will import math library to use sqrt(), this will used to #calculate square root.

import math
def area_square(a):
area1=float(a*a);
print("Area of square is:",area1)
def area_circle(r):
area2=float(3.14*r*r);
print("Area of circle is:",area2)
def area_rectangle(a,b):
area3=float(a*b);
print("Area of rectangle is:",area3)
def area_triangle(x,y):
area4=float((x*y)/2);
print("Area of triangle is:",area4)
def peri_square(a):
peri1=float(4*a);
print("Perimeter of square is:",peri1)
def peri_circle(r):
peri2=float(2*3.14*r);
print("Perimter of circle is:",peri2)
def peri_triangle(a,b):
hypotenuse=float(math.sqrt(a*a+b*b))
peri3=float(a+b+hypotenuse)
print("Perimter of right angled triangle is:",peri3)
def peri_rectangle(a,b):
peri4=float(2*(a+b))
print("Perimter of rectangle is:",peri4)

side=float(input("enter the side of square:"))
area_square(side)
print()
peri_square(side)
length=float(input("enter the length of rectangle:"))
base=float(input("enter the base of right angled triangle:"))
height=float(input("enter the height of right angled triangle:"))
area_triangle(base,height)
peri_triangle(base,height)
```

Output:

```enter the side of square:4
Area of square is: 16.0

Perimeter of square is: 16.0
Area of circle is: 28.259999999999998
Perimter of circle is: 18.84
enter the length of rectangle:5
Area of rectangle is: 15.0
Perimter of rectangle is: 16.0
enter the base of right angled triangle:4
enter the height of right angled triangle:3
Area of triangle is: 6.0
Perimter of right angled triangle is: 12.0
>>>```

## Program 4.To calculate Simple and Compound interest.

```# Simple and Compound Interest

# Reading principal amount, rate and time
principal = float(input('Enter amount: '))
time = float(input('Enter time: '))
rate = float(input('Enter rate: '))

# Calcualtion
simple_interest = (principal*time*rate)/100
compound_interest = principal * ( (1+rate/100)**time - 1)

# Displaying result
print('Simple interest is: %f' % (simple_interest))
print('Compound interest is: %f' %(compound_interest))
```

Output:

```Enter amount: 500
Enter time: 5
Enter rate: 12
Simple interest is: 300.000000
Compound interest is: 381.170842
>>>```

## Program 5.To calculate profit-loss for a given Cost and Sell Price.

```cp=float(input("Enter the Cost Price : "));

sp=float(input("Enter the Selling Price : "));

if cp==sp:

print("No Profit No Loss")

else:

if sp>cp:

print("Profit of ",sp-cp)

else:

print("Loss of ",cp-sp)
```

Output:

```Enter the Cost Price : 575
Enter the Selling Price : 623
Profit of 48.0
>>>```
```Enter the Cost Price : 545
Enter the Selling Price : 545
No Profit No Loss
>>>```
```Enter the Cost Price : 545
Enter the Selling Price : 523
Loss of 22.0
>>>```

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

```# Python program to calculate monthly EMI (Equated Monthly Installment)

# EMI Formula = p * r * (1+r)^n/((1+r)^n-1)

# If the interest rate per annum is R% then
# interest rate per month is calculated using:

# Monthly Interest Rate (r) = R/(12*100)

# Varaible name details:
# p = Principal or Loan Amount
# r = Interest Rate Per Month
# n = Number of monthly installments

p = float(input("Enter principal amount: "))
R = float(input("Enter annual interest rate: "))
n = int(input("Enter number of months: " ))

# Calculating interest rate per month
r = R/(12*100)

# Calculating Equated Monthly Installment (EMI)
emi = p * r * ((1+r)**n)/((1+r)**n - 1)

print("Monthly EMI = ", emi)
```

Output:

```Enter principal amount: 12000
Enter annual interest rate: 12.5
Enter number of months: 18
Monthly EMI = 734.57478867545
>>>```

## Program 7.To calculate tax – GST / Income Tax.

```Original_price=float(input("Enter original Price:-"))

Net_price = float(input("Enter Net Price:-"))

GST_amount = Net_price - Original_price

GST_percent = ((GST_amount * 100) / Original_price)

print("GST = ",end='')

print(GST_percent,end='')

print("%")
```

Output:

```Enter original Price:-345
Enter Net Price:-356
GST = 3.1884057971014492%
>>>```

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

```#create empty list

mylist = []

number = int(input('How many elements to put in List: '))

for n in range(number):

element = int(input('Enter element '))

mylist.append(element)

# Sort list elements
sorted_list = sorted(mylist)

print("Sorted elements in list : ",sorted_list)

'''Now we will print values using their index
(as third smallest element will be at index 2
and the third largest elemt wiill be at index -3)
'''

print(("The Third smallest element in list is:",sorted_list[2]))

print(("The Third largestest element in list is:",sorted_list[-3]))
```

Output:

```How many elements to put in List: 6
Enter element 34
Enter element 45
Enter element 23
Enter element 32
Enter element 65
Enter element 56
Sorted elements in list : [23, 32, 34, 45, 56, 65]
('The Third smallest element in list is:', 34)
('The Third largestest element in list is:', 45)
>>>```

## Program 10.1 To find the sum of squares of the first 100 natural numbers.

```'''Python Program to find the sum of
squares of the first 100 natural numbers'''

sum = 0

for numbers in range(1, 101):

sum = sum + (numbers*numbers)

print("Sum of squares is : ", sum)
```

Output:

```Sum of squares is : 338350
>>>```

## Program 10.2 Python Program to find the sum of square of given number.

```number = int(input("Enter any number : "))

sum = 0

for numbers in range(1,number+1):

sum = sum + (numbers*numbers)

print("Sum of squares is : ", sum)```

Output:

```Enter any number : 4
Sum of squares is : 30
>>>

Enter any number : 3

Sum of squares is : 14

>>>```

## Program 11.To print the first ‘n’ multiples of a given number.

```# Python Program to print the first ‘n’ multiples of a given number

num=int(input("Enter a number whose multiples to find-"))

length=int(input("Enter length upto which you want to find multiples-"))

for i in range (1,length+1):

print(i*num)
```

Output:

```Enter a number whose multiples to find-5
Enter length upto which you want to find multiples-4
5
10
15
20
>>>```

```Enter a number whose multiples to find-2
Enter length upto which you want to find multiples-13
2
4
6
8
10
12
14
16
18
20
22
24
26
>>>```

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

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

## Program 14. To print the number of occurrences of a given alphabet in a given string.

```# Python Program to Count Occurrence of an alphabate in a String

string = input("Enter any String: ")
char = input("Enetr any alphabate to count its occurrence: ")

count = 0
for i in range(len(string)):
if(string[i] == char):
count = count + 1

print("Total Occurrence count of", char, " in string is = ",count)
```

Output:

```Enter any String: "practical file for class 11 informatics practices term 1"
Enetr any alphabate to count its occurrence: "i"
('Total Occurrence count of', 'i', ' in string is = ', 5)
>>>```
```Enter any String: "practical file for class 11 informatics practices term 1"
Enetr any alphabate to count its occurrence: "z"
('Total Occurrence count of', 'z', ' in string is = ', 0)
>>>```

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

```'''Python Program to create a dictionary to
store names of states and their capitals.'''

states = dict()

no_of_states = int(input("Enter the number of states :"))

for i in range(no_of_states):

state_name = input("Enter name of state :")

state_capital = input("Enter capital of state :")

states[state_name] = state_capital

print("Dictionary is created :",states)

name = input("Enter the name of state to display capital:")

print(states[name])
```

Output:

```Enter the number of states :3
Enter name of state :"UTTAR PRADESH"
Enter capital of state :"LUCKNOW"
Enter name of state :"UTTRAKHAND"
Enter name of state :"PUNJAB"
Enter capital of state :"CHANDIGARH"
Enter the name of state to display capital:"PUNJAB"
CHANDIGARH
>>>```

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

```'''Python Program to Create a dictionary of students
to store names and marks obtained in 5 subjects.'''
#Empty Dictionary

students = dict()

no_of_student = int(input("Enter number of students :"))

for i in range(no_of_student):

std_name = input("Enter names of student :")

marks= []

for j in range(5):#Range for 5 subjects

mark = int(input("Enter marks :"))

marks.append(mark)

students[std_name] = marks

print("Dictionary of student created :")

print(students)```

Output:

```Enter number of students :3
Enter names of student :"Amit"
Enter marks :67
Enter marks :78
Enter marks :78
Enter marks :98
Enter marks :87
Enter names of student :"Sumit"
Enter marks :56
Enter marks :67
Enter marks :89
Enter marks :98
Enter marks :87
Enter names of student :"Neetu"
Enter marks :88
Enter marks :78
Enter marks :79
Enter marks :67
Enter marks :87
Dictionary of student created :
{'Amit': [67, 78, 78, 98, 87], 'Neetu': [88, 78, 79, 67, 87], 'Sumit': [56, 67, 89, 98, 87]}
>>>```

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

Data Management: SQL Commands

1. To create a database

2. To create a student table with the student id, class, section, gender, name, dob, and marks as attributes where the student id is the primary key.

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

4. To delete the details of a particular student in the above table.

5. To increase marks by 5% for those students who have Rno more than 20.

6. To display the entire content of the table.

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

8. To find the average of marks from the student table.

9. To find the number of students, who are from section ‘A’.

10. To add a new column email in the above table with appropriate data type.

11. To add the email ids of each student in the previously created email column.

12. To display the information of all the students, whose name starts with ‘AN’ (Examples: ANAND, ANGAD,..)

13. To display Rno, Name, DOB of those students who are born between ‘2005- 01-01’ and ‘2005-12-31’.

14. To display Rno, Name, DOB, Marks, Email of those male students in ascending order of their names.

15. To display Rno, Gender, Name, DOB, Marks, Email in descending order of their marks.

16. To display the unique section available in the table.