Class X_C_13 Practical File 2024-25
Class X_C_13 Practical File 2024-25
I am Kahan
In [11]: # Task 1: WAP to check whether the given number is odd or even
n= int(input("Enter a number: "))
if n%2==0:
print("The number is even")
else:
print("The number is odd")
Enter a number: 3
The number is odd
[2, 5, 8, 1.8]
['Water', 2, 5, 8, 1.8, '34rtr', 'I', 'am', 'Groot']
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 1/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
len(A)
print(len(A))
A.append(50)
print(A)
A.extend([51,52,'pqr'])
print(A)
A.insert(4,"Kahan")
print(A)
x= A.count(11)
print (x)
x= A.index(46)
print(x)
A.remove(46)
print(A)
A.pop(3)
print(A)
7
[11, 16, 46, 46, 29, 'abc', 'xyz', 50]
[11, 16, 46, 46, 29, 'abc', 'xyz', 50, 51, 52, 'pqr']
[11, 16, 46, 46, 'Kahan', 29, 'abc', 'xyz', 50, 51, 52, 'pqr']
1
2
[11, 16, 46, 'Kahan', 29, 'abc', 'xyz', 50, 51, 52, 'pqr']
[11, 16, 46, 29, 'abc', 'xyz', 50, 51, 52, 'pqr']
In [16]: A=[1,5,4,2,3]
A.reverse()
print(A)
A.sort()
print(A)
for i in range(len(A)):
print (A[i])
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 2/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
[3, 2, 4, 5, 1]
[1, 2, 3, 4, 5]
1
2
3
4
5
In [10]: #Task 5: WAP to take elements from the user and put them in a list
A= []
n =int(input("Enter the number of elements for list: "))
for i in range(1,n+1):
a= int(input("Enter a number: "))
A.append(a)
print(A)
In [16]: #Task 6: WAP to take numbers from the user, categorize them into odd and even and print two lists of odd and even numbers sepe
O= []
E= []
n =int(input("Enter the number of elements for list: "))
for i in range(1,n+1):
a= int(input("Enter a number: "))
if a%2==0:
E.append(a)
else:
O.append(a)
print("This is the list of odd numbers-",O,
"and this is the list of even numbers-",E)
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 3/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
O= []
E= []
for i in range(1,7):
a= int(input("Enter a number: "))
if a%2==0:
E.append(a)
else:
O.append(a)
print("This is the list of odd numbers-",O,
"and this is the list of even numbers-",E)
Enter a number: 1
Enter a number: 2
Enter a number: 3
Enter a number: 4
Enter a number: 5
Enter a number: 6
This is the list of odd numbers- [1, 3, 5] and this is the list of even numbers- [2, 4, 6]
In [1]: #(Q.2) Create a list of 10 elements using list and reverse them all
A=[]
for i in range(1,11):
n= int(input("Enter a number: "))
A.append(n)
A.reverse()
print(A)
Enter a number: 1
Enter a number: 2
Enter a number: 3
Enter a number: 4
Enter a number: 5
Enter a number: 6
Enter a number: 7
Enter a number: 8
Enter a number: 9
Enter a number: 10
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
In [4]: #(Q.3) Create a list of first 10 even numbers, add 1 to each list element and print the final list
A=[]
for i in range(1,21):
a=int(input("Enter a number"))
if a%2==0:
A.append(a+1)
print(A)
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 4/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
Enter a number2
Enter a number4
Enter a number6
Enter a number8
Enter a number10
Enter a number12
Enter a number14
Enter a number16
Enter a number18
Enter a number20
Enter a number22
Enter a number24
Enter a number26
Enter a number28
Enter a number30
Enter a number32
Enter a number34
Enter a number35
Enter a number36
Enter a number38
[3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]
In [3]: #(Q.4) WAP to compute total marks of different subjects. Also compute the percentage. Create a list to take subject and its ma
s=int(input("Enter the number of subjects: "))
TM=0
S=[]
M=[]
MP=[]
for i in range (0,s):
Sn=input("Enter name of the subject: ")
S.append(Sn)
m=int(input("Enter marks out of 80: "))
M.append(m)
p= (m/80)*100
MP.append(p)
TM= TM+m
print("Subjects:",S)
print ("Marks respectively:",M)
print ("Your percentages for marks of each subject respectively are: ",MP)
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 5/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
Enter the number of subjects: 6
Enter name of the subject: Mathematics
Enter marks out of 80: 80
Enter name of the subject: Science
Enter marks out of 80: 78
Enter name of the subject: SS
Enter marks out of 80: 76
Enter name of the subject: English
Enter marks out of 80: 76
Enter name of the subject: Sanskrit
Enter marks out of 80: 78
Enter name of the subject: AI
Enter marks out of 80: 80
Subjects: ['Mathematics', 'Science', 'SS', 'English', 'Sanskrit', 'AI'] Marks respectively: [80, 78, 76, 76, 78, 80] Your perc
entages for marks of each subject respectively are: [100.0, 97.5, 95.0, 95.0, 97.5, 100.0]
In [2]: #(Q.6) WAP to take 10 sequential elements and store it in a list. Delete every second element and print the final list
Series1= []
for i in range (0,10):
n=(input("Enter n: "))
Series1.append(n)
for i in range(1,6):
Series1.pop(i)
print(Series1)
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 6/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
Enter n: 1
Enter n: 2
Enter n: 3
Enter n: 4
Enter n: 5
Enter n: 6
Enter n: 7
Enter n: 8
Enter n: 9
Enter n: 10
['1', '3', '5', '7', '9']
In [3]: #(Q.7) WAP to take monthly income of employees and calculate the annual income tax to be paid by them.
age=int(input("Enter age in years: "))
if age>=60 and age<=80:
minc= int(input("Enter monthly salary: "))
ainc= minc*12
if ainc<300000:
print("No Income Tax will be levied.")
elif ainc>=300000 and ainc<500000:
it= (ainc/20)
print("The annual income tax to be paid by you is",it)
elif ainc>=500000 and ainc<1000000:
it= (ainc/5)
print("The annual income tax to be paid by you is",it)
else:
it= (ainc*(3/10))
print("The annual income tax to be paid by you is",it)
else:
print("Your income tax could not be calculated because, your age does not fulfill the age validity criterion")
FALSE
TRUE
In [7]: #(Q.2)
for i in range(100):
print(i)
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 7/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 8/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 9/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
94
95
96
97
98
99
In [8]: #(Q.3)
number=0
while number<=5:
if number<=5:
number= number +1
print(number, end=" ")
1 2 3 4 5 6
In [13]: #(Q.4)
if 4 + 5 ==10:
print("TRUE")
else:
print("FALSE")
print("TRUE")
FALSE
TRUE
In [14]: #(Q.5)
x= [10.0, 11.0, 12.0]
y= x[1]
print(y)
11.0
In [17]: #(Q.6)
b=1
for a in range(1,10,2):
b+= a+2
print(b)
36
In [16]: #(Q.7)
name="Pooja"
age=15
print(name,"you are",age,"now, and", end=" ")
print("you will be", age+1,"next year")
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 10/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
In [18]: #(Q.8)
my_list= ['apple','banana','cherry','apple','grape']
result= my_list.count('apple')
print(result)
In [21]: #(Q.9)
my_list = [2,7,1,3,5]
my_list.sort( )
In [22]: #(Q.10)
my_list= [3, 1, 4, 4, 1, 5, 9, 2, 6, 5, 3, 5]
output= my_list.count(5)
print(result)
1 1 1 1 1
2 2 2 2
3 3 3
4 4
5
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 13/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
for j in range(65,1+i):
print(chr(i), end=" ")
print()
A
B B
C C C
D D D D
E E E E E
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 14/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
Enter number of rows: 5
*
* *
* * *
* * * *
* * * * *
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 15/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
print("@",end=" ")
print()
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 16/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
for j in range(1, i+1):
print(k, end=" ")
print()
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 17/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
In [5]: #(6.15)
n=int(input("Number of rows: "))
for i in range(n,0,-1):
if i%2!=0:
for j in range(1,i+1):
print("@",end=" ")
else:
for j in range(1,i+1):
print("*",end=" ")
print()
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 18/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
Number of rows: 5
@ @ @ @ @
* * * *
@ @ @
* *
@
A A A
A A
A
In [1]: #(6.18)
n = 3
x=65
for i in range(n,0,-1):
for j in range(1, i+1):
print(chr(x), end=" ")
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 19/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
x=x+1
print()
A A A
B B
C
In [37]: #(6.19)
n = 3
x=67
for i in range(n,0,-1):
for j in range(1, i+1):
print(chr(x), end=" ")
x=x-1
print()
C C C
B B
A
In [6]: #6.20) WAP to ask the user to enter number of rows and make the following pattern
"""
*
* *
* * *
* *
*
"""
n=int(input("Enter the no. of rows: "))
k=0
for i in range (1,n+1):
k=k+1
for j in range (i,k+i):
print("*",end=" ")
print()
for i in range(n-1,0,-1):
for j in range(1,i+1):
print("*", end=" ")
print()
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 20/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
In [22]: #(6.22) WAP to print the same pattern for numbers for alphabets
n=68
for i in range(65,n):
for j in range (65,i+1):
print(chr(i),end=" ")
print()
for i in range(n-2,64,-1):
for j in range (65,1+i):
print(chr(i),end=" ")
print()
A
B B
C C C
B B
A
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 22/23
12/4/24, 11:13 PM Class X_C_13 Kahan Shah
Enter number of rows: 4
* * * *
In [ ]:
file:///Users/KahanPlayzz/Desktop/My Daily work/Math and Science sources/Class X_C_13 Kahan Shah Practical File 2024-25 (Part-1) (1).html 23/23
In [1]: import numpy as np
marks= np.array([50, 60, 85])
print(marks)
[50 60 85]
[ 10 20 30 40 50 60 70 80 90 100]
[22 5 2 30 9]
import numpy as n
a= n.array(42)
print(a)
42
import numpy as n
a= n.random.randint(20,size=(1,7))
print(a)
[[12 9 4 10 7 3 8]]
0.9017053547483365
[[4 2]
[0 0]]
[[1. 1. 1.]
[1. 1. 1.]]
[[7 7 5]
[2 2 1]
[2 7 6]]
[[7 7 7 7 7 7 7]
[7 7 7 7 7 7 7]
[7 7 7 7 7 7 7]
[7 7 7 7 7 7 7]
[7 7 7 7 7 7 7]]
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_4280\2943293493.py in <module>
1 import numpy as n
----> 2 a = n.random.randomfloat()
3 print(a)
[7 7 7 7 7]
[-5 -3 -1 1 3]
[ 1 4 9 16 25]
[0 0 0 1 2]
[1 2 3 1 1]
Dimensions: 1
Shape: (5,)
max value: 5
order: [1 2 3 4 5]
sum: 15
2.0 km/hr
In [44]: #(Q.1)
#Sub Part 1
import numpy as n
marks= n.array([45,55,55,44,78,90,60])
m= marks + 2
print(m)
#Sub Part 2
fd= marks//5
print(fd)
#Sub Part 3
mean= n.mean(marks)
median= n.median(marks)
mode= n.argmax(n.bincount(marks))
print("Mean:", mean)
print("Median:", median)
print("Mode:", mode)
[47 57 57 46 80 92 62]
[ 9 11 11 8 15 18 12]
Mean: 61.0
Median: 55.0
Mode: 55
In [ ]:
In [ ]: #Matplotlib
In [ ]: