[go: up one dir, main page]

0% found this document useful (0 votes)
29 views50 pages

Blank

The document contains a certificate for a student named Vanshika Lalwani from Agarwal Vidya Vihar in Surat, India. It certifies that the programs entered in the Informatics Practices practical file have been satisfactorily completed by Vanshika during the 2022-23 academic year. The document also includes 15 programming problems and their solutions in Python.

Uploaded by

Vanshika Lalwani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views50 pages

Blank

The document contains a certificate for a student named Vanshika Lalwani from Agarwal Vidya Vihar in Surat, India. It certifies that the programs entered in the Informatics Practices practical file have been satisfactorily completed by Vanshika during the 2022-23 academic year. The document also includes 15 programming problems and their solutions in Python.

Uploaded by

Vanshika Lalwani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 50

AGARWAL VIDYA VIHAR, SURAT.

NAME : Vanshika Lalwani

ROLL NO.: 12

CLASS: XI-Com. B

SUBJECT: Informatics Practice

ACADEMIC YEAR: 2022-23

TOPIC: IP Practical file


AGARWAL VIDYA VIHAR, SURAT.

CERTIFICATE
The programs entered in this file has been satisfactorily performed by

Roll no __12__, Ms./Miss. __Vanshika Lalwani__ studying in

AGARWAL VIDYA VIHAR, SURAT class 11th Commerce during

academic year 2022-23.

__________________
__________________
Subject Teacher’s Sign. Examiner’s
Sign.
____________________
___________________
Principal’s Sign. School
Stamp

Index
1. Take two integer values from user and print greatest among them.
2. A shop will give discount of 10% if the cost of purchased quantity is more
than 1000.Ask user for quantity
suppose, one unit will cost 100. Print total cost for user.
3. A student will not be allowed to sit in exam if his/her attendance is less than
75%.
Take following input from user Number of classes held, Number of classes
attended.And print percentage of class attended.
4. Write a program that reads three numbers and prints them in ascending
order.
5. Write a program to check the given year is leap year or not. If a year is
divisible by 4 then it is leap year but if the year is century year like 2000,
1900, 2100 then it must be divisible by 400.
6. Write a program to find factorial of a given number.
7. Write a program to find sum of the series : S = 1 + X + X2 + X3 + X4 +……
+Xn
8. Write a python script to print first 15 elements of Fibonacci series.
Fibonacci series – 0 1 1 2 3 5 8 13………

9. Write a program to print the following pattern :


(a) A
AB
A BC
A BCD
A BCDE
(b) 5 5 5 5 5
4444
333
22
1
(c) 5 4 3 2 1
4321
321
21
1

10.Input a number and check if the number is a prime number.

11.Write a program to read a list of n integers (positive as well as negative).


Create two new lists, one having all positive numbers and the other having
all negative numbers from the given list. Print all three lists.

12.Write a program to find the largest and the second largest elements in a
given list of elements.
13.Write a program to read a list of n integers and find their median.
Note: The median value of a list of values is the middle one when they are
arranged in order. If there are two middle values then take their average.
Hint: Use an inbuilt function to sort the list.

14.Write a program to read a list of elements. Modify this list so that it does not
contain any duplicate elements i.e. all elements occurring multiple times in
the list should appear only once.
15.Write a program to create a list of elements. Input an element from the user
that has to be inserted in the list. Also input the position at which it is to be
inserted.
16.Write a program to create a dictionary to store names of states and their
capitals.
17.Write a program to create a dictionary to store assets, liabilities and capital
of a company. After creating the dictionary display, assets and liabilities of
the company and test of the accounting equation holds true.
18.Write a program to check if a dictionary is empty.
19.Write a program to create a third dictionary from two dictionaries having
some common keys, in way so that the values of common keys are added in
the third dictionary.
20.Write a program to input your friend’s names and their phone numbers and
store them in the dictionary as the key-value pair. Perform the following
operations on the dictionary:
a. Display the name and phone number of all your friends.
b. Add a new key-value pair in this dictionary and display the modified
dictionary.
c. Delete a particular friend from the dictionary.
d. Modify the phone number of an existing friend.
e. Check if a friend is present in the dictionary or not.
f. Display the dictionary in sorted order of names.

Program-1:
Take two integer values from user and print greatest
among them.
Code:
#Python program to find Largest of two Numbers using if-else
statements
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
if(a>=b):
print(a,"is greater")
else:
print(b,"is greater")

Output:

Program-2:
A shop will give discount of 10% if the cost of purchased
quantity is more than 1000. Ask user for quantity. Suppose
one unit will cost 100.Print total cost for user.
Code:
x=int(input("Enter quantity:"))
if x*100>1000:
print("the cost of user is",x*100-(x*100*0.1))
else:
print("the total cost of user is",x*100)

Output:

Program-3:
A student will not be allowed to sit in exam if his/her
attendance is less than 75%. Take input from user
Number of classes held, Number of classes attended.
Print percentage of class attended.
Code:
x=int(input("enter the number of classes held:"))
y=int(input("enter the number of classes attended:"))
if(x/y)*100>+75:
print("the student had attended”,(x/y)*100,"classes and is
eligible to sit in exam ")
else:
print("the student is not able to sit in exam with",(x/y)*100)
Output:

Program-4:
Program that reads three numbers and prints them in ascending
order.
Code:
num1=int(input("Enter the first number:"))
num2=int(input("Enter the second number:"))
num3=int(input("Enter the third number:"))
if num1<num2 and num1<num3:
if num2<num3:
x,y,z=num1,num2,num3
else:
x,y,z=num1,num3,num2
elif num2<num1 and num2<num3:
if num1<num3:
x,y,z=num2,num1,num3
else:
x,y,z=num2,num3,num1
else:
if num1<num2:
x,y,z=num3,num1,num2
else:
x,y,z=num3,num2,num1
print("The numbers in ascending orders are:",x,y,z)

Output:
Program-5:
Program to check the given year is leap year or not. If a year is
divisible by 4 then it is leap year but if the year is century year
like 2000,1900,2100 then it must be divisible by 400.
Code:
x=int(input("Enter the year:"))
if x%400==0:
print("It is the century leap year")
elif x%4==0 and x%100!=0:
print("It is the leap year")
else:
print("It is not the leap year")

Output:
Program-6:
Write a program to find factorial of a given number.

Code:
f=1
n=int(input("Enter the number:"))
for i in range(n,0,-1):
f=f*i
print(f)
Output:
Program-7:
Write a program to find sum of the series: S = 1 + X + X2 + X3 +
X4 +……+Xn
Code:
x=float(input("enter value:"))
n=int(input("enter value:"))
s=0
for a in range(n+1):
s+=x**a
print("Sum of series is",s)

Output:
Program-8:
Write a program script to print first 15 elements of Fibanacci
series.
Fibonacci series – 0 1 1 2 3 5 8 13………
Code:
f1=0
f2=1
n=int(input("Enter number of series:"))
print()
print(f1,"\t",f2,end='\t')
for i in range(2,n+1):
f3=f1+f2
f1=f2
f2=f3
print(f3,end='\t')

Output:

Program-9:
Write a program to print the following pattern:
(a) A
AB
ABC
ABCD
ABCDE
Code:
n=int(input("enter no. of rows:"))
for i in range(1,n+1):
a=45
for j in range(1,i+1):
print(chr(a),end="")
a+=1
print()
Output:

(b) 5 5 5 5 5
4444
333
22
1
Code:
n=int(input("Enter number:"))
for i in range(n,0,-1):
for j in range(i,0,-1):
print(i,end="")
print()

Output:

(c) 5 4 3 2 1
4321
321
21
1

Code:
for i in range(5,0,-1):
for j in range(i,0,-1):
print(j,end="")
print()

Output:

Program-10:
Input a number and check if the number is a prime number.
Code:
n=int(input("Enter numbers:"))
flag=0
if n>1:
for i in range(2,(n//2)+1):
if n%i==0:
flag=1
break

if flag==0:
print(n,"number is prime.")
else:
print(n,"is not prime.")
else:
print("Enter number greater than 1.")

Output:

Program-11:
Write a program to read a list of n integers (positive as well as
negative). Create two new lists, one having all positive numbers
and the other having all negative numbers from the given list.
Print all three lists.
Code:
l=[]
l1=[]
l2=[]
n=int(input("Enter how many no.u want in your list:"))
for i in range(n):
m=int(input("Enter your number.:"))
l.append(m)
if m>=1:
l1.append(m)
else:
l2.append(m)
print("Here is your original list:\n",l)
print("Here is your positive list:\n",l1)
print("Here is your negative list:\n",l2)

Output:
Program-12:
Write a program to find the largest and the second largest
elements in a given list of elements.
Code:
l=[]
n=int(input("Enter how many number you want:"))
for i in range(n):
m=int(input("Enter your number:"))
l.append(m)
x=sorted(l)
print("Your largest digit in the given list is:",x[-1])
print("Your second largest digit is:",x[-2])
Output:

Program-13:
Write a program to read a list of n integers and find their
median.
Code:
l=[]
n=int(input("Enter how many number do you want in your
list:"))
for i in range(n):
m=int(input("Enter your number here:"))
l.append(m)
l.sort()
print(l)
if n%2==0:
n1=(n//2)
n2=(n//2)+1
m=(l[n1-1]+l[n2-1])/2
print("median of your list is:",m)
else:
n1=(n//2)
m=(l[n1])
print("median of your list is:",m)

Output:
Program-14:
Write a program to read a list of elements. Modify this list so
that it does not contain any duplicate elements i.e. all elements
occurring multiple times in the list should appear only once.
Code:
l=[]
n=int(input("Enter how many number you want in your list:"))
for i in range(n):
m=int(input("Enter your number"))
l.append(m)
ll=[]
for i in l:
if i not in ll:
ll.append(i)
print(l)
print(ll)
Output:
Program-15:
Write a program to create a list of elements. Input an element
from the user that has to be inserted in the list. Also input the
position at which it is to be inserted.
Code:
arr=[12,34,25,56,78,87]
pos=int(input("enter the position where you want to insert the
element:"))
ele=int(input("enter element to insert:"))
print("the list before insertion:",arr)
arr1=arr[:pos-1]+[ele]+arr[pos-1:]
print("the list after insertion:",arr1)
Output:
Program-16:
Write a program to create a dictionary to store names of
States and their Capitals.
Code:
D={}
a=int(input("Enter how many States & Capital do you want:"))
for i in range(a):
S=input("Enter the name of state:")
C=input("Enter the name of capital")
D[S]=C
print(D)
Output:
Program-17:
Write a program to create a dictionary to store assets, liabilities
and capital of a company. After creating the dictionary display,
assets and liabilities of the company and test of the accounting
equation holds true.
Code:
n=int(input("Enter the number of entries:"))
acc_dict=dict()
print()
for i in range(n):
com=input("Enter the name of the company:")
a=float(input("Enter the asset amount:"))
l=float(input("Enter the liability amount:"))
c=float(input("Enter the capital amount:"))
acc_dict[com]=a,l,c
print()
print()
print("Your given dictionary:")
print()
print("Company\t\t","Asset\t\t","Liability\t\t","Capital\t")
print()
for i in acc_dict:
print(i,"/t/t",acc_dict[i][0],"\t",acc_dict[i][1],"\t\t",acc_dict[i]
[2])
print()
for i in acc_dict:
if acc_dict[i][1]+acc_dict[i][2]==acc_dict[i][0]:
print("The accounting equation for",i,"holds True.")
else:
print("The accounting equation for",i,"does not hold True.")

Output:
Program-18:
Write a program to check if a dictionary is empty.
Code:
d={}
n=int(input("Enter how many student you want:"))
for i in range(n):
m=input("Enter your student name:")
b=int(input("Enter your student marks:"))
d[m]=b
print(d)
if(len(d)==0):
print("The dictionary is empty.")
else:
print("The dictionary is not empty.")
Output:

Program-19:
Write a program to create a third dictionary from two
dictionaries having some common keys, in way so that the
values of common keys are added in the third dictionary.
Code:
dict1={}
dict2={}
dict3={}
n=int(input("Enter the number of entries for your first
dictionary:"))
m=int(input("Enter the number of entries for your second
dictionary:"))
print("Enter your first dictionary:")
for i in range(n):
xy=input("Enter your character:")
val=int(input("Enter your value:"))
dict1[xy]=val
print("Enter your second dictionary:")
for i in range(m):
xy=input("Enter your character:")
val=int(input("Enter your value:"))
dict2[xy]=val
print(dict1)
print(dict2)

for i in dict1:
if i in dict2:
dict3[i]=dict1[i]+dict2[i]
print("Your combine key is:",dict3)

Output:

Program-20:
Write a program to input your friend’s names and their phone
numbers and store them in the dictionary as the key-value pair.
Perform the following operations on the dictionary:
a. Display the name and phone number of all your friends.
b. Add a new key-value pair in this dictionary and display the
modified dictionary.
c. Delete a particular friend from the dictionary.
d. Modify the phone number of an existing friend.
e. Check if a friend is present in the dictionary or not.
f. Display the dictionary in sorted order of names.
Code:
#Display the Name and phone number of all your friends.
d={}
d2={}
n=int(input("Enter how many names you want to enter:"))
for i in range(n):
name=input("Enter name of friend:")
number=int(input("Enter phone number:"))
d[name]=number
print("Your dictionary is:\n",d)

#Add a new key-value pair in this dictionary and disqplay


the modified dictionary.
x=input("Enter name of friend which you have to add:")
y=int(input("Enter number of friend:"))
d2[x]=y
d.update(d2)
print("Modified dictionary:\n",d)

#Delete a particular friend name from the dictionary.


z=input("Enter name of friend which you have to delete:")
del d[z]
print("The name has been deleted:\n",d)

#Modify the phone number of an existing friend.


x=input("Enter name of friend whose number you have to
change:")
y=int(input("Enter new number of friend:"))
for x in d:
d[x]=y
print("The number has been modify:\n",d)

#Check if a friend is present in the dictionary or not.


c=input("whose name would you like to check:")
print(c in d)

#Display the dictionary in sorted order of names.


print("Your sorted dictionary is:")
for i in sorted(d):
print("(",i,":",d[i],")",end="")
Output:

MYSQL

1. . Consider the table Hospital given below.


Hospital

No Name Age DEPARTMENT DateOfAdm Charges Sex


1 Sandeep 64 Surgery 23/02/2008 300 M
2 Ravina 24 Orthopedic 20/01/2008 200 F
3 Karan 45 Orthopedic 10/02/2008 200 M
4 Tarun 12 Surgery 01/01/2008 300 F
5 Zubin 36 ENT 12/01/2008 250 M
6 Ketaki 16 ENT 12/02/2008 300 F
7 Ankita 29 Cardiology 20/02/2008 800 F
8 Zareen 45 Gynecology 22/02/2008 Null F
9 Kush 19 Cardiology 13/01/2008 800 M
10 Shailya 31 Medicine 19/02/2008 400 F

(i) To show all information about the patients of cardiology


department.

(ii) To list the names of female patients who are in cardiology


department.
(iii) To display Patient’s name, charges, Age for male patients.

(iv) To count the number of patients with Age > 30.


(v) Increase the charges of male patient in ENT department by
3%.

(vi) Add another column email_id with suitable data type.


(vii) Delete the records of all female patients in Surgery
department.

(viii) Display a report listing name, age, charges and


amount of charges including VAT as 2% on charges
name the column as total charges and keep the data
in ascending order of name.
(ix) Display the details of all the patients who are hospitalised in
February 2008.

(x) Display the charges of various departments . A charge


amount should appear only once.

(xi) SELECT COUNT(DISTINCT Department) FROM


HOSPITAL;
(xii) SELECT MAX(Age) FROM HOSPITAL WHERE
SEX=’M’;

(xiii) SELECT AVG(Charges) FROM HOSPITAL WHERE


SEX=’F’;
(xiv) SELECT SUM(Charges) FROM HOSPITAL WHERE
DATEOFadm < ’12/02/2008’ ;

2) Consider the table STUDENT given below:

RollNo Name Class DOB Gender City Marks


1 Anand XI 6/6/97 M Agra 430
2 Chetan XII 7/5/94 M Mumbai 460
3 Geet XI 6/5/97 F Agra 470
4 Preeti XII 8/8/95 F Mumbai 492
5 Saniyal XII 8/10/95 M Delhi 360
6 Maakhiy XI 12/12/94 F Dubai 256
7 Neha X 8/12/95 F Moscow 324
8 Nishant X 12/6/95 M Moscow 429

(1) Create table student and insert data in it.


(2) Display all the details of student table.
(3) Display rollno , name and marks from student table.

(4) Display all details of students who are studying in class XII.
(5) Display name, city and marks from student table who lived in
Mumbai.

(6) Display only Female students’ names.

(7) Display students’ details in ascending order of name.


(8) Display students’ details in descending order of marks.

(9) Display student’s details for only male students who are in class XI.
(10) Display student’s details for class XII and marks grater than 350.

(11) Display students’ names who lived in Moscow and Mumbai.

(12) Display students’ names which starts with ‘N’.

(13) Display students’ names which contains ‘a’ in it.


(14) Display students’ details who lived in Moscow ,Dubai and Mumbai.

(15) Display students’ details whose marks are 430,429,492,256.

(16) Display students’ details whose marks are not 430,429,492,256.


(17) Display students’ details whose marks are grater than or equl to 300
and less than or equal to 450.

(18) Display the distinct city from the table.

(19) Display the name of city from the table.


THE END

You might also like