0% found this document useful (0 votes)
42 views26 pages

Practical File Amit (2)

The document is a collection of programming exercises that involve writing Python programs to perform various tasks such as calculating sums, averages, areas, and checking conditions like leap years and character cases. Each program includes a brief description, code, and sample output. The exercises cover basic programming concepts and operations, making it suitable for beginners learning Python.

Uploaded by

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

Practical File Amit (2)

The document is a collection of programming exercises that involve writing Python programs to perform various tasks such as calculating sums, averages, areas, and checking conditions like leap years and character cases. Each program includes a brief description, code, and sample output. The exercises cover basic programming concepts and operations, making it suitable for beginners learning Python.

Uploaded by

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

INDEX

Sr.no PROGRAM Teacher signature

1. WAP to calculate the sum of three numbers using the input


function.

2. WAP to calculate the average of three numbers using the input


function.

3. WAP to enter 2 numbers and print the largest number.

4. WAP to calculate the area of a rectangle.

5. WAP to calculate the circumference of a circle.

6. WAP to input temperature of water and print is physical state.

7. WAP to input 3 Side of triangle and print the type of triangle -


equilateral,scalene, isosceles.

8. WAP to enter any number and check it is positive, negative or


zero.

9. WAP to input day number and print corresponding day name for
if input.

10. WAP to input any year and check it is leap year.

11. WAP to check the number of even and odd.

12. WAP to enter Marks of 5 subjects and output average marks.

13. WAP to find the maximum, minimum mean of numeric value


stored in a list.

14. WAP to calculate the BMI.

15. WAP to print the highest and lowest values in the dictionary.

16. WAP to calculate profit or loss for a given cost and selling price.

17. WAP to check if the character is lowercase or uppercase.

18. WAP to enter any age and check if it is a teenager or not.

19. WAP to input any number and check if it is positive or negative


number.
20. WAP to enter the monthly sale of the salesman and give him
commission if the monthly sale is more than 500000 then
commission will be 10% of monthly sale otherwise 5%.

21. WAP to sort three numbers entered by a user

22. WAP to print table of any number.

23. WAP to print 6 times english classes then print 1 times computer
classes.

24. print the any message of python.

25. WAP to print the star pattern.

26. WAP to print the using for append () function.

27. WAP to print the using for extend () function.

28. WAP to enter names of employees and their salaries as input


and store them in a dictionary using a for loop.

29. WAP to input the total number of sections and stream name in
11th class and display all information on the output screen.

30. WAP to count the frequency of an element in a given list.

PROGRAM - 1

# WAP to calculate the sum of three numbers using the input function.

num1=int(input(“enter the first number=”)) num2=int(input(“enter the second number=”))


num3=int(input(“enter the third number=”))
Sum=num1+num2+num3
Print(“sum of three number=”,sum)

OUTPUT

enter the first number=25


enter the second number=57
enter the third number45
sum of three number= 127

[Program finished]
PROGRAM - 2

# WAP to calculate the average of three numbers using the input function.

num1=int(input("enter the first number="))


num2=int(input("enter the second number="))
num3=int(input("enter the third number="))
avg=num1+num2+num3/3
print("avg of three number=",avg)

OUTPUT

enter the first number=10


enter the second number=20
enter the third number=25
avg of three number= 38.333333333333336

[Program finished]

PROGRAM - 3

# WAP to enter 2 numbers and print the largest number.

print("enter the two numbers :")


num1=int(input())
num2=int(input())
if num1>num2:
print("largest number=",num1)
else:
print("largest number=",num2)

OUTPUT

enter the two numbers :


46
78
largest number= 78

[Program finished]

PROGRAM - 4
# WAP to calculate the area of a rectangle.
length=int(input("enter the length="))
breath=int(input("enter the breath="))
area=length*breath
print("area of rectangle=",area)

OUTPUT

enter the length=45


enter the breath=55
area of rectangle= 2475

[Program finished]

PROGRAM - 5

# WAP to calculate the circumference of a circle.

radius=float(input("enter the radius of circle="))


area=3.14*radius*radius
circum=20*5.40*radius
print("area of circle is=",area)
print("circumference of circle is=",circum)

OUTPUT

enter the radius of circle=20


area of circle is= 1256.0
circumference of circle is= 2160.0

[Program finished]

PROGRAM - 6

# WAP to input temperature of water and print is physical state.

temp=int(input("enter temperature of water"))


if temp > 100 :
print("gaseous state")
elif temp < 0 :
print("solid state")
else :
print("liquid state")

OUTPUT
enter temperature of water90
liquid state

enter temperature of water-200


solid state

enter temperature of water150


gaseous state

[Program finished]

PROGRAM - 7

# WAP to input 3 Side of triangle and print the type of triangle - equilateral,scalene, isosceles.

s1=int(input("enter side 1"))


s2=int(input("enter side 2"))
s3=int(input("enter side 3"))
if s1==s2==s3 :
print("equilateral")
elif s1!=s2!=s3!= s1 :
print("scalene")
else :
print("isosceles")

OUTPUT

enter side 1 80
enter side 2 50
enter side 3 20
scalene

[Program finished]

PROGRAM - 8

# WAP to enter any number and check it is positive, negative or zero.

num1=int(input("enter the number"))


if num1 > 0 :
print("positive number")
elif num1 < 0 :
print("negative number")
else :
print("zero")

OUTPUT

enter the number 635


positive number

[Program finished]

PROGRAM - 9

# WAP to input day number and print corresponding day name for if input.

n1=int(input("enter the number="))


if n1==1 :
print("sunday")
elif n1==2 :
print("monday")
elif n1==3 :
print("tuesday")
elif n1==4 :
print("wednesday")
elif n1== 5 :
print("thursday")
elif n1== 6 :
print("friday")
elif n1==7 :
print("saturday")

OUTPUT

enter the number= 7


saturday

[Program finished]

PROGRAM - 10

# WAP to input any year and check it is leap year.

n1=int(input("enter the year"))


if n1% 4==0 :
print("the year is leap year")
OUTPUT

enter the year 2024


the year is leap year

[Program finished]

PROGRAM - 11

# WAP to check the number of even and odd.

num=int(input("enter the number of even"))


print(num)
num=int(input("enter the number of odd"))
print(num)

OUTPUT

enter the number of even 50


50
enter the number of odd 70
70

[Program finished]

PROGRAM - 12

# WAP to enter Marks of 5 subjects and output average marks.

m1=int(input("enter first subject marks:"))


m2=int(input("enter second subject marks:"))
m3=int(input("enter third subject marks:"))
m4=int(input("enter fourth subject marks:"))
m5=int(input("enter fifth subject marks:"))
avg=(m1+m2+m3+m4+m5) / 5 ;
print("average marks =" , avg)

OUTPUT

enter first subject marks:80


enter second subject marks:75
enter third subject marks:65
enter fourth subject marks:70
enter fifth subject marks:60
average marks = 70.0

[Program finished]

PROGRAM - 13

# WAP to find the maximum, minimum mean of numeric value stored in a list.

list1=[12,18,34,9,21]
max=list1[0]
min=list1[0]
n=len(list1)
sum=0

for item in list1 :


sum=sum+item
if item > max :
max=item
elif item < min :
min=item
print("maximum value in list is ", max)
print("minimum value in list is ", min)
print("average value is ", sum/n)

OUTPUT

maximum value in list is 34


minimum value in list is 9
average value is 18.8

[Program finished]

PROGRAM - 14

# WAP to calculate the BMI.

bmi=int(input("enter the bmi ="))


if bmi >= 18 :
print("you are healthy")
print("enjoy your life")
else :
print("make your body healthy")
OUTPUT

enter the bmi = 24


you are healthy
enjoy your life

[Program finished]

PROGRAM - 15

# WAP to print the highest and lowest values in the dictionary.

my_dict = {'a': 5, 'b': 10, 'c': 3, 'd': 8}


highest_value = max(my_dict.values())
lowest_value = min(my_dict.values())

print("The highest value in the dictionary is:", highest_value)


print("The lowest value in the dictionary is:", lowest_value)

OUTPUT

The highest value in the dictionary is: 10


The lowest value in the dictionary is: 3

[Program finished]

PROGRAM - 16

# WAP to calculate profit or loss for a given cost and selling price.

cost_price=float(input("Enter the cost Price of an Item :"))


selling_price=float(input("Enter the Selling Price of an Item :"))
if (selling_price > cost_price):
profit = selling_price - cost_price
print("Profit :",profit)
elif( cost_price > selling_price):
loss = cost_price - selling_price
print("Loss :",loss)
else:
print("No Profit No Loss")

OUTPUT

Enter the cost Price of an Item :250


Enter the Selling Price of an Item :280
Profit : 30.0

[Program finished]

PROGRAM - 17

# WAP to check if the character is lowercase or uppercase.

ch = input("Please Enter Your Own Character : ")

if(ch.isupper()):
print("The Given Character ", ch, "is an Uppercase")
elif(ch.islower()):
print("The Given Character ", ch, "is a Lowercase")
else :
print("The Given Character ", ch, "is Not a Lower or Uppercase")

OUTPUT

Please Enter Your Own Character : M


The Given Character M is an Uppercase

[Program finished]

PROGRAM - 18

# WAP to enter any age and check if it is teenager or not.

n=int(input("enter your age :"))


if n <= 18 :
print("teenager")
else :
print("not teenager")

OUTPUT

enter your age : 16


teenager

enter your age : 20


not teenager

[Program finished]
PROGRAM - 19

# WAP to input any number and check it is a positive or negative number.

n=int(input("enter a number ="))


print("Enter a number: ");
if (n <= 0.0) :
if (n == 0.0) :
print("You enter 0 ") ;
else :
print(" enter the negative number");

else :
print("enter the positive number") ;

OUTPUT

Enter a number: 500


enter the positive number

[Program finished]

PROGRAM - 20

# WAP to enter the monthly sales of the salesman and give him commission if the monthly sale
is more than 500000 then commission will be 10% of monthly sale otherwise 5%.

sales=float(input("enter monthly sales amount : $"))

commission = 0.05
if sales > 500000 :
commission = 0.1
print("you earned:$+str(sales*commission")

OUTPUT

enter monthly sales amount : $400000


you earned:$+str(sales*commission

[Program finished]

PROGRAM - 21
# WAP to sort three numbers entered by a user.

a = float(input("Enter the first number : "))


b = float(input("Enter the second number: "))
c = float(input("Enter the third number:"))
if a > b:
a,b = b,a
if a > c:
a,c = c,a
if b > c:
b,c = c,b

OUTPUT

Enter the first number : 47


Enter the second number: 78
Enter the third number:67
47.0 < 67.0 < 78.0

[Program finished]

PROGRAM - 22

# WAP to print table of any number.

num=int(input("enter any number"))


for i in range (1,11):
print(num,'x',i,'=',num*i)

OUTPUT

enter any number 18


18 x 1 = 18
18 x 2 = 36
18 x 3 = 54
18 x 4 = 72
18 x 5 = 90
18 x 6 = 108
18 x 7 = 126
18 x 8 = 144
18 x 9 = 162
18 x 10 = 180

[Program finished]
PROGRAM - 23

# WAP to print 6 times account classes then print 1 times gabs classes.

num=5
for i in range (1,6):
print("account classes")
print("gabs classes")

OUTPUT

account classes
account classes
account classes
account classes
account classes
gabs classes

[Program finished]

PROGRAM - 24

# print the any message of python.

a="python"
for i in a:
print("character=",i)

OUTPUT

character= p
character= y
character= t
character= h
character= o
character= n

[Program finished]

PROGRAM - 25

# WAP to print the star pattern.


for j in range (2,8):
for i in range (1,j):
print ("*",end=" ")
print()

OUTPUT

*
**
***
****
*****
******

[Program finished]

PROGRAM - 26

# WAP to print the using for append () function.

fruits=['apple','orange','banana','mango']
fruits.append("cherry")
print(fruits)

OUTPUT

['apple', 'orange', 'banana', 'mango', 'cherry']

[Program finished]

PROGRAM - 27

# WAP to print the using for extend () function.

fruits = ['apple', 'banana', 'cherry']


more_fruits = ['mango', 'pineapple', 'grapes']
fruits.extend(more_fruits)
print(fruits)

OUTPUT

['apple', 'banana', 'cherry', 'mango', 'pineapple', 'grapes']

[Program finished]
PROGRAM - 28

# WAP to enter names of employees and their salaries as input and store them in a dictionary
using a for loop.

num=int(input("enter the number of employees :"))


count=1
employee=dict ( )
for count in range (num):
name=input("enter the name of the employee :")
salary=int(input("enter the salary :"))
employee [name]=salary
print("\n\nemployee_name\tsalary")
for k in employee :
print (k,'\t\t',employee[k])

OUTPUT

enter the number of employees :3


enter the name of the employee :aryan
enter the salary :75000
enter the name of the employee :shiva
enter the salary :80000
enter the name of the employee :ankit
enter the salary :90000

employee_name salary
aryan 75000
shiva 80000
ankit 90000

[Program finished]

PROGRAM - 29

# WAP to input the total number of sections and stream name in 11th class and display all
information on the output screen.

class xi=dict( )
n=int(input("enter total number of sections in xi class :"))
i=1
while i<=n :
a=input("enter section:")
b=input("enter stream name:")
class xi [a]=b
i=i+1
print("class",'\t',"section",'\t',"stream name")
for i in class xi :
print("xi",'\t',i,'\t',class xi [i])

OUTPUT

enter total number of sections in xi class :3


enter section:A
enter stream name:commerce with math
enter section:B
enter stream name:arts with eco
enter section:C
enter stream name:science with bio
class section stream name
xi A commerce with math
xi B arts with eco
xi C science with bio

[Program finished]

PROGRAM - 30

# WAP to count the frequency of an element in a given list.

My_list = [1, 2, 3, 4, 2, 2, 3, 1, 5]
element_to_count = 2
frequency = count_frequency(my_list, element_to_count)
print(f"The frequency of {element_to_count} is: {frequency}")

OUTPUT

The frequency of 2 is: 3

[Program finished]
S.no Practical list Teacher signature

1. Write a SQL query to create a database.

2. Write a SQL query to create a student table with the


student I'd, class, section,gender,name,dob, and marks as
attributes where the student I'd is the primary key.

3. Write a SQL query to insert the details of at least 10


students in the student table.

4. Write a SQL query to delete the details of a particular


student in the student table.

5. Write a SQL query to increase the marks by 5% for those


students who are scoring Marks more than 30.

6. Write a SQL query to display the entire content of the


table.

7. Write a SQL query to display student_id,name and marks


of those students who are scoring Marks more than 30.

8. Write a SQL query to find the average marks from the


student table.

9. Write a SQL query to find the number of students, who are


from section 'A'.

10. Write a SQL query to add a new column email in the


student table with appropriate data type.

11. Write a SQL query to add the email id's of each student in
the previously created email column.

12. Write a SQL query to display the information of all the


students, whose name starts with 'S'.

13. Write a SQL query to display the student_id,name,dob of


those students who are born between ‘2005-01-01’ and
‘2005-12-31’.

14. Write a SQL query to display the


student_id,name,dob,marks, email of male student in
ascending order of there name.
15. Write a SQL query to display the
student_id,gender,name,dob,marks, email of
student in descending order of their marks.
16. Write a SQL query to display the unique section name
from the student table.

17. Shiva,a student of class Xll, created a table "class". Grade


is one of the columns of this table.
Write a SQL query to find the details of students whose
grade have not been entered.

18. Shiva is using a table with the following details:


Students(Name, Class, Stream_id, Stream_Name)
Write the SQL query to display the names of students who
have not been assigned any stream or have been
assigned Stream_Name that end with “computers”.

Query - 1
Write a SQL query to create a database.

Create database student ;

Query ok,1 row affected

Query - 2
Write a SQL query to create a student table with the student I'd, class,
section,gender,name,dob, and marks as attributes where the student I'd is the primary
key.

create table student(sid int primary key,name varchar(25),class


numeric(2),section char(2),gender char(1),dob date,marks int);
Query - 3
Write a SQL query to insert the details of at least 10 students in the student
table.

Insert into student values(1,'Amit’ ,11th,03,'Male',’2008-03-20);


Insert into student values(2,'riya', 11th,11, 'Female',’2008-06-14');
Insert into student values(3,’Ankit’
,10th,15,’male’,’2007-05-20’);
Insert into student values(4,’mahi’
,11th,16,'Female','2006-04-11');
Insert into student values(5,'ram', 11th,17,'Male',’2008-08-25');
Insert into student values(6,’jiya', 9th,18, 'Female',’2007-07-13’);
Insert into student values(7,'Ravi’ ,9th,14,'Male',’2006-01-17');
Insert into student values(8,’neha’ ,10th,08,'Female',’2009-03-26');
Insert into student values(9,’golu’ ,12th,12,'Male','2005-06-14');
Insert into student values(10,’rama’,12th,21,’female’,’2005-05-25’);

Query - 4
Write a SQL query to delete the details of a particular student in the student
table.

DELETE
FROM student
WHERE name = 'Amit Singh' ;

Query - 5
Write a SQL query to increase the marks by 5% for those students who are
scoring Marks more than 30.

UPDATE student
SET marks = marks * 1.05
WHERE marks > 30;

Query - 6
Write a SQL query to display the entire content of the table.

SELECT *
FROM student;

Query - 7
Write a SQL query to display student_id,name and marks of those students
who are scoring Marks more than 30.

SELECT student_id, name, marks


FROM student
WHERE marks > 30;

Query - 8
Write a SQL query to find the average marks from the student table.

SELECT AVG(marks) AS average_marks


FROM student;

Query - 9
Write a SQL query to find the number of students, who are from section 'A'.

SELECT COUNT(*)
FROM student
WHERE section = 'A';

Query - 10
Write a SQL query to add a new column email in the student table with
appropriate data type.

ALTER TABLE student


ADD email VARCHAR(255);
Query - 11
Write a SQL query to add the email id's of each student in the previously
created email column.

UPDATE student
SET email = CASE
WHEN student_id = 1 THEN '[email protected]'
WHEN student_id = 2 THEN '[email protected]'
WHEN student_id = 3 THEN '[email protected]'
WHEN student_id = 4 THEN '[email protected]'
WHEN student_id = 5 THEN '[email protected]'
WHEN student_id = 6 THEN '[email protected]'
WHEN student_id = 7 THEN '[email protected]'
WHEN student_id = 8 THEN '[email protected]'
WHEN student_id = 9 THEN '[email protected]'
WHEN student_id = 10 THEN '[email protected]'
ELSE email
END;

Query - 12
Write a SQL query to display the information of all the students, whose
name starts with 'S'.

SELECT *
FROM student
WHERE name LIKE 'S%';

Query - 13
Write a SQL query to display the student_id,name,dob of those students
who are born between ‘2005-01-01’ and ‘2005-12-31’.

SELECT student_id, name, dob


FROM student
WHERE dob BETWEEN '2005-01-01' AND '2005-12-31';
Query - 14
Write a SQL query to display the student_id,name,dob,marks, email of
male student in ascending order of there name.

SELECT student_id, name, dob, marks, email


FROM student
WHERE gender = 'Male'
ORDER BY name ASC;

Query - 15
Write a SQL query to display the student_id,gender,name,dob,marks, email
of student in descending order of their marks.

SELECT student_id, gender, name, dob, marks, email


FROM student
ORDER BY marks DESC;

Query - 16
Write a SQL query to display the unique section name from the student
table.

SELECT DISTINCT section


FROM student;

Query - 17
Shiva,a student of class Xll, created a table "class". Grade is one of the
columns of this table.
Write a SQL query to find the details of students whose grade have not
been entered.

SELECT *
FROM class
WHERE grade IS NULL;

Query - 18
Shiva is using a table with the following details:
Students(Name, Class, Stream_id, Stream_Name)
Write the SQL query to display the names of students who have not been
assigned any stream or have been assigned Stream_Name that end with
“computers”.

SELECT Name
FROM Students
WHERE Stream_Name IS NULL OR Stream_Name LIKE '%computers';

You might also like