IP Prctical File Class XI
IP Prctical File Class XI
2. Write a python program to find the sale price of an item with a given cost and discount (%).
cost=float(input("Enter the cost : "))
dis=cost*dis_per/100
sel_price=cost-dis
print("Discount: ",dis)
Output of program 2:
#process
si = (p*r*t)/100
ci= p * ( (1+r/100)**t - 1)
#output
print('Simple interest is: %.2f' % (si))
print('Compound interest is: %.2f' %(ci))
Ouptut for Program 4:
5. Write a program to calculate profit-loss for a given Cost and Sell Price.
#input cost and sales amount
cost = float(input("Enter the cost of the product: "))
sale_amt = float(input("Enter the Sales Amount: "))
#declare a variable to store profit and loss
amt=0
#Actual process to compute profit or loss
if(cost > sale_amt):
amt = cost - sale_amt
print("Total Loss Amount = ",amt)
elif(cost < sale_amt):
amt = sale_amt - cost
print("Total Profit =",amt)
else:
print("No Profit No Loss!!!")
Output for Program 5:
large = l[0]
sec_large = l[0]
third_large = l[0]
for i in l :
if i > large:
third_large = sec_large
sec_large = large
large = i
elif i > sec_large :
third_large = sec_large
sec_large = i
elif i > third_large:
third_large = i
10. Write a program to find the sum of squares of the first 100 natural numbers.
sum1 = 0
for i in range(1, 101):
sum1 = sum1 + (i*i)
print("Sum of squares is : ", sum1)
Output of Program 10:
11. Write a program to print the first ‘n’ multiples of a given number.
#input
n = int(input("Enter the number to display multiples:"))
m = int(input("Enter the number to display n multiples:"))
#computing multiples
multip = range(n, (n * m) + 1, n)
print(list(multip))
Output of Program 11:
13. Write a program to print the words starting with a particular alphabet in a user entered string.
txt=input("Enter the text:")
al=input("Enter alphabet to print the words:")
for i in txt.split():
if i.startswith(al):
print(i)
Output for program 13
14. Create a dictionary of students to store names and marks obtained in 5 subjects.
students={'Aksh':[34,46,48,33,47],'Bhavik':[44,45,48,43,42]}
print(students)
Output of program 14
3. Create a student table with the student id, class, section, gender, name, dob,
andmarks as attributes where the student id is the primary key.
create table student
(studentid int(4) primary key,
class char(2),
section char(1),
gender char(1),
name varchar(20),
dob date,
marks decimal(5,2));
12. Find the number of students, who are from section ‘A’.
alter table student add column email varchar(20);
15. Display the information of all the students, name contains ‘sh’
select * from student where name like 'sh%';
16. Display the information of all the students, name starts with ‘sh’
select * from stduent where name like 'sh%';
19. Display stduentid, Gender, Name, DOB, Marks, Email in descending order of
their marks.
select studentid, gender, name, dob, marks, email from student order
by marks desc;