INFORMATION PRACTICES JOURNAL(2024-2025)
PROGRAMING IN PYTHON
1 TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Table of content
2 TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
3 TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q1. TO FIND THE AVERAGE AND GRADE FOR GIVEN MARKS.
eng=float(input("Enter English Marks:"))
BS=float(input("Enter BUSINESS STUDIES Marks:"))
ECO=float(input("Enter ECONOMICS Marks:"))
ACC=float(input("Enter ACCOUNTANCY Marks:"))
IP=float(input("Enter IP Marks:"))
average=float((eng+BS+ECO+ACC+IP)/5)
print("Average of Marks is",average)
if average>90:
print("You scored GRADE A")
elif average<=90 and average >80:
print("You scored GRADE B")
elif average<=70 and average <80:
elif average<=60 and average <70:
print("You scored GRADE D")
elif average<=50 and average <60:
print("you scored gradeEnter English Marks:56
Enter English Marks:56
Enter BUSINESS STUDIES Marks:60
Enter ECONOMICS Marks:70
Enter ACCOUNTANCY Marks:71
Enter IP Marks:74
Average of Marks is 66.2
You scored GRADE C
4 TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q2. TO FIND THE SALE PRICE OF AN ITEM WITH GIVEN COST
AND DISCOUNT (%)
a=float(input("enter price"))
b=float(input("enter discount %"))
c=a*b/100
sp=a-c
print("cost price:",a)
print("discount:",b)
print("selling price:",sp)
enter price 100
enter discount % 69
cost price: 100.0
discount: 69.0
selling price: 31.0
5 TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q3. TO CALCULATE PERIMETER/CIRCUMFERENCE AND AREA OF
SHAPES SUCH AS TRIANGLE, RECTANGLE,CIRCLE,SQUARE
print("enter number to select shape:")
print("1.triangle")
print("2.rectangle")
print("3.square")
print("4.circle")
n=int(input("enter your choice 1,2,3,4:"))
if (n==1):
s1=int(input("enter the length of side 1:"))
s2=int(input("enter the length of base"))
s3=int(input("enter the length of side 3:"))
h=int(input("enter the height of triangle:"))
print("perimeter of triangle is",(s1+s2+s3))
print("area of triangle is",(1/2*s2*h))
elif (n==2):
l=int(input("enter the length of rectangle:"))
b=int(input("enter the base of the rectangle"))
print("perimeter of the rectangle is:",(2*(l+b)))
print("area of the rectangle is:",(l*b))
elif (n==3):
s=int(input("enter the length of the side of square:"))
print("area of square is",(s*s))
elif(n==4):
r=int(input("enter the radius of the circle:"))
print("circumference of the circle is",(2*3.14))
print("area of the circle is",(3.14*r*r))
6 TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
else:
print("invalid option")
enter number to select shape:
1.triangle
2.rectangle
3.square
4.circle
enter your choice 1,2,3,4: 4
enter the radius of the circle: 5
circumference of the circle is 6.28
area of the circle is 78.5
7 TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q4. TO CALCULATE SIMPLE AND COMPOUND INTEREST
p=float(input("enter amount:"))
t=float(input("enter years:"))
r=float(input("enter rate:"))
a=(p*t*r)/100
c=p*((1+r/100)**t-1)
print("simple interest",a)
print("compound interest",c)
enter amount: 50000
enter years: 5
enter rate: 6
simple interest 15000.0
compound interest 16911.278880000013
8 TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q5. TO CALCULATE PROFIT AND LOSS FOR GIVEN COST AND
SELL PRICE
sp=float(input("enter the selling price:"))
cp=float(input("enter the cost price:"))
if sp>cp:
profit=sp-cp
profit_per=(profit*100)//cp
print("the profit is :-",profit)
print("the profit percentage is :-",profit_per)
elif sp<cp:
loss=cp-sp
loss_per=(loss*100)//cp
print('the loss is:-',loss)
print("the loss percentage is :-",loss_per)
else:
print("no profit no loss") L PRICE
Enter the selling price :100
Enter the cost price :75
The profit is :25.0
The profit percentage is : 33.0
9 TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q6. TO CALCULATE THE EMI FOR AMOUNT,PERIOD AND
INTEREST
amount=float(input("enter the base amount"))
period=float(input("enter the time period"))
rate=float(input("enter rate of interest"))
interest=amount*period*rate/100
emi=total/(period*12)
print("emi amount is",emi)
Enter the base amount 2550
Enter the time period 2
Enter rate of interest 31
Emi amount is 172.125
10
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q7. TO CALCULATE TAX-GST/INCOME TAX
Selling_price = int(input(“enter selling price of the product:”))
Gst_rate =18
Gst_price =selling_price*18/100
Net_price =selling_price+gst_price
Print(“gst applied rs:{gst_price}at gst rate”,gst_rate)
Print(“total cost of the product afterapplying gst=”,net_price)
Enter selling price of the product:110
Gst applied rs:{gst_price} at gst rate 18
Total cost of the product after applying gst =129.8
11
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q8. TO FIND THE LARGEST AND THE SMALLEST NUMBER IN LIST
l=eval(input("enter a list of numbers"))
larg=1[0]
small=1[0]
for fornum in l:
if fornum>larg:
larg=fornum
if fornum<small:
smallest=fornum
print("largest:",larg)
print("smallest:",small)
Enter a list of numbers [1,2,3,4,5,6,7,8,9]
Largest: 9
Smallest: 1
12
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q9. TO FIND THE THIRD LARGEST/SMALLEST NUMBER IN A
LIST
num=eval(input("enter a list of numbers:"))
largest_num=float('-inf')
second_largest_num=float('-inf')
third_largest_num=float('-inf')
for i in num:
if i>largest_num:
third_largest_num=second_largest_num
second_largest_num=largest_num
largest_num=i
elif i>second_largest_num:
third_largest_num=second_largest_num
second_largest_num=i
elif i>third_largest_num:
third_largest_num=i
smallest_num=float('-inf')
second_smallest_num=float('-inf')
third_smallest_num=float('-inf')
for i in num:
if i>smallest_num:
third_smallest_num=second_smallest_num
second_smallest_num=smallest_num
smallest_num=i
elif i>second_smallest_num:
third_smallest_num=second_smallest_num
second_smallest_num=i
13
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
elif i>third_smallest_num:
third_smallest_num=i
print("third smallest number of the list is{}".format(third_smallest_num))
print("third largest number of the list is{}".format(third_largest_num))
enter a list of numbers:1,2,3,4,5,6
third smallest number of the list is 3
third largest number of the list is 4
14
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q10. TO FIND THE SUM OF SQUARE OF THE FIRST 100
NATURAL NUMBERS
n=100
sum_of_squares=sum(i**2 for i in range(1,n+1))
print("sum of squares of te first 100 natural numbers:",sum_of_squares)
sum of squares of te first 100 natural numbers: 338350
15
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q11.TO PRINT THE FIRST ‘N’ MULTIPLES FOR GIVEN NUMBERS
given_numbers=int(input("enter the numbers:"))
multiples_count=int(input("enter the value of n:"))
print("the first",multiples_count,"multiples of",given_numbers,"are:")
for i in range(1,multiples_count+1):
multiples=given_number*1
print(given_number,"x",i,"=",multiples)
Enter the number: 3
Enter the value of n: 9
The first 9 multiples of 3 are:
3*1=3
3*2=6
3*3=9
3*4=12
3*5=15
3*6=18
3*7=21
3*8=24
3*9=27
16
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q12.TO COUNT THE NUMBER OF VOWEL PRESENT IN THE
USER’S STRING
user_input=input("enter a string:")
vowels="aeiouAEIOU"
vowel_count=0
for char in user_input:
if char in vowels:
vowel_count+=1
print("the number of vowels in the entered string is:",vowel_count)
enter a string : hello i am happy
the number of vowels in the entered string is: 5
17
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q13.TO PRINT THE WORDS STARTING WITH A PARTICULAR
ALPHABET IN A GIVEN STRING
user_input=input("enter a string:")
starting_alphabet=input("enter the alphabet to filter words:").lower()
words=user_input.split()
selected_words=[word for word in words if word.startswith (starting_alphabet)]
if selected_words:
print("words starting with'{starting_alphabet}':")
for words in selected_words:
print(word)
else:
print("no words fount strting with '{starting_alphabet}'.")
enter a string: kinjal
enter the alphabet to filter words: k
words strting with ‘k’:
kinjal
18
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q14. TO PRINT NUMBER OF OCCURRENCE FOR A GIVEN
ALPHABET IN A GIVEN STRING
user_input=input("enter a string:")
target_alphabet=input("enter the alphabet to count occurrences:").lower()
defcount_occurrences(user_string, target_alphabet):
count=0
for char in user_string:
if char ==target_alphabet:
count+=1
return count_occurences(user_input,target_alphabet)
printt("the number of occurrences of '{target_alphabet}'in the entered string is:{result}")
Enter a string: hellooo
Enter the alphabet to count occurrences: e
The number of occurrences of ‘e’ in the entered string is : 1
19
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q15.CREATE A DICTIONARY TO STORE NAME OF STATES AND
THEIR CAPITAL
State_capitals={
‘rajasthan’ : ’jaipur’,
‘gujarat’ : ‘gandhinagar’,
‘maharasthra’ : ‘mumbai’,
‘aasam’ : ‘dispur’,
‘uttarpradesh’ : ‘lucknow’}
Print(“capital of rajasthan:,state_capitals[‘rajasthan’])
Print(“capital of maharasthra: :,state_capitals[‘maharasthra’])
Print(“capital of assam: :,state_capitals[‘assam’])
Print(“capital of Gujarat: :,state_capitals[‘gujarat’])
Print(“capital of uttarpradesh :,state_capitals[‘uttarpradesh’])
Capital of rajasthan : jaipur
Capital of mharasthra : mumbai
Capital of assam : dispur
Capital of gujarat : gandhinagar
Capital of uttarpradesh : lucknow
20
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q16.CREATE A DICTIONARY OF STUDENTS TO STORE NAMES
AND MARKS OBTAINED IN 5 SUBJECTS
Students={
‘ayush’:[85,90,78,92,88],
‘shah’:[76,88,92,80,85],
‘rainaa’:[90,82,79,88,94],}
Print(‘marks obtained by rainaa in the third subject:”,students[‘rainaa’][2])
Marks obtained by rainaa in the third subjects: 79
21
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Q17. TO PRINT HIGHEST AND LOWEST VALUE IN DICTIONARY
STUDENTS={
‘AYUSH’:[85,90,78,92,88]
‘SHAH’:[76,88,92,80,85]
‘RAINAA’:[90,82,79,88,94],
}
ALL_MARKS=[MARK FOR MARKS IN STUDENTS.VALUES()
FOR MARK IN MARKS]
HIGHEST_MARK=MAX(ALL_MARKS)
LOWEST_MARK=MAX(ALL_MARKS)
PRINT(“HIGHEST MARK:”,HIGHEST_MARK)
PRINT(“LOWEST MARK:”,LOWEST_MARK)
HIGHEST MARK: 94
LOWEST MARK: 76
22
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
DATA MANAGEMENT :
SQL COMMANDS
23
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
TABLE OF CONTENT
24
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
25
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
PROGRAM 1.
To create a database .
26
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
Program 2.
Create a student table with the studentid , name , and marks as
attributes where the student id is the primary key .
27
TUSHAR SINGH
INFORMATION PRACTICES JOURNAL(2024-2025)
PROGRAM 3.
To insert the details of at least 10 students in the above table.
28
TUSHAR SINGH