0% found this document useful (0 votes)
40 views27 pages

Malpani Caste Programming Guide

Uploaded by

maulee diwanji
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)
40 views27 pages

Malpani Caste Programming Guide

Uploaded by

maulee diwanji
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

11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [2]:
1 print("siya")

siya

In [3]: 1 print("malpani")

malpani

In [4]: 1 print(12+5)

17

In [2]:
1 #WAP write a number to check whether the number is odd or even store odd elments
2 n=int(input("enter a number"))
3 if n%2==0:
4 print("even")
5 else:
6 print("odd")

enter a number78
even

localhost:8888/notebooks/XB_26_SIYA [Link] 1/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [5]:
1 #list
2 A1=[11,23,34,45,56]
3 print(A1[1:3])

[23, 34]

In [3]: 1 #list
2 A1=['blah','lala','tata','byee','heyy']
3 print(A1[-1::-5])

['heyy']

In [1]: 1 #list(;length of input)


2 a=[11,23,45,67,'abc']
3 print(len(a))

In [4]:
1 #list (in append only add one no)
2 a=[11,23,45,67,'abc']
3 [Link](89)
4 print(a)

[11, 23, 45, 67, 'abc', 89]

localhost:8888/notebooks/XB_26_SIYA [Link] 2/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [5]: 1 #list (in extend can add more than one no.)
2 a=[11,23,45,67,'abc']
3 [Link]([90,'xyz',234])
4 print(a)

[11, 23, 45, 67, 'abc', 90, 'xyz', 234]

In [8]: 1 #list
2 a=[11,23,45,67,'abc']
3 [Link](1,96)
4 print(a)

[11, 96, 23, 45, 67, 'abc']

In [11]:
1 #list(tells how many times no. repeated)
2 a=[67,23,45,67,'abc',67,89,67]
3 x=[Link](67)
4 print(x)

In [14]: 1 #list(place of no.)


2 a=[11,23,45,67,'abc']
3 x=[Link](11)
4 print(x)

localhost:8888/notebooks/XB_26_SIYA [Link] 3/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [10]: 1 #list(removes a no.)


2 a=[11,23,45,67,'abc']
3 [Link](67)
4 print(a)

[11, 23, 45, 'abc']

In [13]: 1 #list(gives a specific mo.)


2 a=[11,23,45,67,'abc']
3 print([Link](1))
4 ​

23

In [18]: 1 #list(ascending order)(all the inputs should be same like if no. only no. & if al
2 a=[11,45,69,67]
3 [Link]()
4 print(a)

[11, 45, 67, 69]

In [19]: 1 #list(input gets reversed)


2 a=[11,23,45,67,'abc']
3 [Link]()
4 print(a)

['abc', 67, 45, 23, 11]

localhost:8888/notebooks/XB_26_SIYA [Link] 4/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [20]: 1 #list
2 a=[]
3 print(a)

[]

In [21]: 1 #list
2 a=list()
3 print(a)

[]

In [26]: 1 #list(if the no. u are writing in print is there in ur input then it will print T
2 a=[11,23,45,67,'abc']
3 print(2 in a)

False

In [29]: 1 #list
2 b='siya'
3 b1=list(b)
4 print(b1)

['s', 'i', 'y', 'a']

localhost:8888/notebooks/XB_26_SIYA [Link] 5/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [19]: 1 #create a list of 6 elements using list and chk no. is odd or even and store even
2 ODD=[]
3 EVEN=[]
4 len=int(input("enter the length of the list:"))
5 for i in range(1,len+1):
6 num=int(input("enter no.:"))
7 if num%2==0:
8 [Link](num)
9 else:
10 [Link](num)
11 print(ODD)
12 print(EVEN)

enter the length of the list:6


enter no.:29
enter no.:24
enter no.:1
enter no.:86
enter no.:90
enter no.:87
[29, 1, 87]
[24, 86, 90]

In [ ]:
1 #create a list of first ten even no. add 1 to each list elment and print the fina
2 a=[]
3 for i in range(1,21):
4 f=int(input("first 21 no."))
5 z=f%2
6 if z==0:
7 [Link](f+1)
8 print("final list",a)

localhost:8888/notebooks/XB_26_SIYA [Link] 6/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [21]: 1 #write a program using list to take 10 numbers from user and print the list in re
2 print("HELLO USER")
3 a=[]
4 for i in range(1,11):
5 n=int(input("enter ele:"))
6 [Link](n)
7 print("list before reverse",a)
8 [Link]()
9 print("list after reverse",a)

HELLO USER
enter ele:5
enter ele:6
enter ele:8
enter ele:4
enter ele:2
enter ele:0
enter ele:8
enter ele:6
enter ele:4
enter ele:63
list before reverse [5, 6, 8, 4, 2, 0, 8, 6, 4, 63]
list after reverse [63, 4, 6, 8, 0, 2, 4, 8, 6, 5]

localhost:8888/notebooks/XB_26_SIYA [Link] 7/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [5]: 1 #for loop


2 a=list()
3 len=int(input("enter the length of the list:"))
4 for i in range(1,len+1):
5 n=int(input("enter ele:"))
6 [Link](n)
7 print(a)

enter the length of the list:7


enter ele:9
enter ele:6
enter ele:8
enter ele:3
enter ele:1
enter ele:5
enter ele:2
[2, 5, 1, 3, 8, 6, 9]

In [1]: 1 #create a list of first ten even numbers add 1 to each list element and print the
2 a=list()
3 for i in range(1,11):
4 if i%2==0:
5 [Link](i+1)
6 print(a)

[3, 5, 7, 9, 11]

localhost:8888/notebooks/XB_26_SIYA [Link] 8/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [2]: 1 #create a list of first 20 elements in list A store only even elements in list B
2 A=list()
3 B=list()
4 for i in range (1,21):
5 [Link](i)
6 if i%2==0:
7 [Link](i)
8 print(A)
9 print(B)

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

In [7]: 1 #wap to fid no.s that are divisible by 3 and multiple of 5 between 1200 and 2200
2 A=list()
3 for i in range (1200,2201):
4 if i%3==0 and i%5==0:
5 [Link](i)
6 print(A)

[1200, 1215, 1230, 1245, 1260, 1275, 1290, 1305, 1320, 1335, 1350, 1365, 1380, 1
395, 1410, 1425, 1440, 1455, 1470, 1485, 1500, 1515, 1530, 1545, 1560, 1575, 159
0, 1605, 1620, 1635, 1650, 1665, 1680, 1695, 1710, 1725, 1740, 1755, 1770, 1785,
1800, 1815, 1830, 1845, 1860, 1875, 1890, 1905, 1920, 1935, 1950, 1965, 1980, 19
95, 2010, 2025, 2040, 2055, 2070, 2085, 2100, 2115, 2130, 2145, 2160, 2175, 219
0]

localhost:8888/notebooks/XB_26_SIYA [Link] 9/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [19]: 1 #wap to delete any second element from the list of given ten elements
2 A=[1,2,3,4,5,6,7,8,9,11]
3 for i in range(1,11):
4 [Link](i)
5 i=i+2
6 print(A)

[1, 3, 4, 5, 6, 7, 8, 9, 11]
[1, 3, 5, 6, 7, 8, 9, 11]
[1, 3, 5, 7, 8, 9, 11]
[1, 3, 5, 7, 9, 11]
[1, 3, 5, 7, 9]

---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_2976\[Link] in <module>
2 A=[1,2,3,4,5,6,7,8,9,11]
3 for i in range(1,11):
----> 4 [Link](i)
5 i=i+2
6 print(A)

IndexError: pop index out of range

localhost:8888/notebooks/XB_26_SIYA [Link] 10/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [20]: 1 #wap to delete any second element from the list of given ten elements
2 A=[1,2,3,4,5,6,7,8,9,10]
3 for i in range(0,11):
4 [Link](i)
5 i=i+3
6 print(A)

[2, 3, 4, 5, 6, 7, 8, 9, 10]
[2, 4, 5, 6, 7, 8, 9, 10]
[2, 4, 6, 7, 8, 9, 10]
[2, 4, 6, 8, 9, 10]
[2, 4, 6, 8, 10]

---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_2976\[Link] in <module>
2 A=[1,2,3,4,5,6,7,8,9,10]
3 for i in range(0,11):
----> 4 [Link](i)
5 i=i+3
6 print(A)

IndexError: pop index out of range

localhost:8888/notebooks/XB_26_SIYA [Link] 11/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [10]:
1 # tb pg 240 q10
2 a=list()
3 age=int(input("enter the age"))
4 if age>60 or age<80 or age==60 or age==80:
5 n=int(input("monthly income"))
6 ai=n*12
7 print("annual income",ai)
8 else:
9 print("thank youu")
10 if ai<300000 or ai==300000:
11 ait=0
12 print("your annual income tax i:",ait)
13 elif ai>300000 or ai<500000:
14 ait=ai*5/100
15 print(" your annual income tax i:",ait)
16 elif ai>500000 and ai<=1000000:
17 ait=ai*20/100
18 print("your annual income tax i:",ait)
19 elif ai>1000000:
20 ait=ai*30/100
21 print(" your annual income tax i:",ait)

enter the age76


monthly income5000000000000000
annual income 60000000000000000
your annual income tax i: 3000000000000000.0

In [16]:
1 #wapp last digit for any given no.
2 n=int(input("enter the number"))
3 last_dig=n%10
4 print(last_dig)

enter the number7555


5

localhost:8888/notebooks/XB_26_SIYA [Link] 12/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [18]: 1 #wapp first digit of any given no.(works only for 2 digit)
2 n=int(input("enter the number"))
3 first_dig=n//10
4 print(first_dig)

enter the number98


9

In [20]: 1 #wapp first digit of any given no.(works only for 3 digit)
2 n=int(input("enter the number"))
3 Q=n//10
4 f=Q//10
5 print(f)

enter the number234


2

In [10]:
1 #wap to reverse a no.(question 3 of lab set 2)
2 a=[]
3 num=int(input("enter a number"))
4 R=num%10
5 Q=num//10
6 R1=Q%10
7 Q1=Q//10
8 print(R,R1,Q1)

enter a number345
5 4 3

localhost:8888/notebooks/XB_26_SIYA [Link] 13/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [2]: 1 #wap to chk whether the number input from the user is a palindrome or [Link]
2 num=int(input("enter a number"))
3 temp=num
4 rev= 0
5 while (num > 0):
6 dig=num % 10
7 rev=rev*10+dig
8 num=num//10
9 if(temp==rev):
10 print("the no. is palindrome.")
11 else:
12 print("not a palindrome.")

enter a number767
the no. is palindrome.

localhost:8888/notebooks/XB_26_SIYA [Link] 14/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [14]: 1 #wap to display multiplication table of any given no.(q5 of lab set 2)
2 n=int(input("enter a number"))
3 for i in range(0,11):
4 f=i*n
5 print(n,"*",i,"=",f)

enter a number98
98 * 0 = 0
98 * 1 = 98
98 * 2 = 196
98 * 3 = 294
98 * 4 = 392
98 * 5 = 490
98 * 6 = 588
98 * 7 = 686
98 * 8 = 784
98 * 9 = 882
98 * 10 = 980

localhost:8888/notebooks/XB_26_SIYA [Link] 15/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [14]:
1 #wap to display the following half pyramid pattern(q6 of lab set 2)
2 #tracing: i=1,range(1,4),j=1,range(1,2)
3 # j=2,range(2,2)X
4 # i=2,range(2,4),j=1,range(1,3)
5 # j=2,range(2,3)
6 # j=3,range(3,3)X
7 # i=3,range(3,4),j=1,range(1,4)
8 # j=2,range(2,4)
9 # j=3,range(3,4)
10 # j=4,range(4,4)X
11 # i=4,range(4,4)X
12
13 n=int(input("no. of rows"))
14 for i in range(0,n+1):
15 for j in range(1,i+1):
16 print("*",end=" ")
17 print()
18
19

no. of rows8

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

localhost:8888/notebooks/XB_26_SIYA [Link] 16/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [3]: 1 #wap to display the following half pyramid pattern(q6 of lab set 2)
2 #tracing: i=1,range(1,4),j=1,range(1,2)
3 # j=2,range(2,2)X
4 # i=2,range(2,4),j=1,range(1,3)
5 # j=2,range(2,3)
6 # j=3,range(3,3)X
7 # i=3,range(3,4),j=1,range(1,4)
8 # j=2,range(2,4)
9 # j=3,range(3,4)
10 # j=4,range(4,4)X
11 # i=4,range(4,4)X
12
13 n=int(input("no. of rows"))
14 for i in range(0,n+1):
15 for j in range(1,i+1):
16 print(j,end=" ")
17 print()
18
19

no. of rows7

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7

localhost:8888/notebooks/XB_26_SIYA [Link] 17/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [13]: 1 #wap to display the following half pyramid pattern(q6 of lab set 2)
2 #tracing: i=1,range(1,4),j=1,range(1,2)
3 # j=2,range(2,2)X
4 # i=2,range(2,4),j=1,range(1,3)
5 # j=2,range(2,3)
6 # j=3,range(3,3)X
7 # i=3,range(3,4),j=1,range(1,4)
8 # j=2,range(2,4)
9 # j=3,range(3,4)
10 # j=4,range(4,4)X
11 # i=4,range(4,4)X
12
13

no. of rows7

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
7 7 7 7 7 7 7

In [7]: 1 for i in range(65,91):


2 print(chr(i),end='')
3

ABCDEFGHIJKLMNOPQRSTUVWXYZ

localhost:8888/notebooks/XB_26_SIYA [Link] 18/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [32]: 1 n=int(input("no. of rows"))


2 for i in range(1,n+1):
3 for j in range(1,i+1):
4 print("siya",end=" ")
5 print()
6

no. of rows4
siya
siya siya
siya siya siya
siya siya siya siya

In [20]: 1 #65-91 is alpshabet range.......chr is character


2 n=int(input("enter no. of rows: "))
3 for i in range(65,65+n):
4 for j in range(65,i+1):
5 print(chr(j),end='')
6 print()
7

enter no. of rows: 5


A
AB
ABC
ABCD
ABCDE

localhost:8888/notebooks/XB_26_SIYA [Link] 19/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [6]: 1 n=int(input("enter no. of rows: "))


2 for i in range(65,65+n):
3 for j in range(65,i+1):
4 print(chr(i),end='')
5 print()
6

enter no. of rows: 5


A
BB
CCC
DDDD
EEEEE

In [8]: 1 n=int(input("no. of rows"))


2 for i in range(n,0,-1):
3 for j in range(1,i+1):
4 print("*",end=" ")
5 print()
6

no. of rows6
* * * * * *
* * * * *
* * * *
* * *
* *
*

localhost:8888/notebooks/XB_26_SIYA [Link] 20/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [16]: 1 n=int(input("no. of rows"))


2 for i in range(n,0,-1):
3 for j in range(1,i+1):
4 print(j,end=" ")
5 print()
6
7

no. of rows3
1 2 3
1 2
1

In [10]: 1 n=int(input("no. of rows"))


2 for i in range(n,0,-1):
3 for j in range(1,i+1):
4 print(i,end=" ")
5 print()
6

no. of rows8
8 8 8 8 8 8 8 8
7 7 7 7 7 7 7
6 6 6 6 6 6
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1

localhost:8888/notebooks/XB_26_SIYA [Link] 21/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [6]: 1 number=1
2 n=int(input("no. of rows"))
3 for i in range(n,0,-1):
4 for j in range(1,i+1):
5 print(number,end=" ")
6 number+=1
7 print()
8

no. of rows5
1 2 3 4 5
6 7 8 9
10 11 12
13 14
15

In [34]: 1 m=0
2 n=int(input("no. of rows"))
3 for i in range(n,0,-1):
4 m=m+1
5 for j in range(1,i+1):
6 print(m,end=" ")
7 print()
8

no. of rows4
1 1 1 1
2 2 2
3 3
4

localhost:8888/notebooks/XB_26_SIYA [Link] 22/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [44]: 1 n=int(input("no. of rows"))


2 for i in range(n,0,-1):
3 for j in range(1,i+1):
4 print(chr(65),end=" ")
5 print()
6

no. of rows3
A A A
A A
A

In [22]: 1 n=int(input("no. of rows"))


2 for i in range(64+n,64,-1):
3 for j in range(65,i+1):
4 print(chr(i),end=" ")
5 print()
6

no. of rows5
E E E E E
D D D D
C C C
B B
A

localhost:8888/notebooks/XB_26_SIYA [Link] 23/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [45]: 1 n=int(input("no. of rows"))


2 for i in range(64+n,64,-1):
3 for j in range(65,i+1):
4 print(chr(j),end=" ")
5 print()

no. of rows3
A B C
A B
A

In [55]:
1 ​
2

no. of rows4
A A A A
A A A
A A

localhost:8888/notebooks/XB_26_SIYA [Link] 24/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [2]: 1 a=int(input("enter the no."))


2 b=65
3 for i in range(a+1,0,-1):
4 for j in range(1,i):
5 print(chr(b),end=" ")
6 b=b+1
7 print("")

enter the no.4


A A A A
B B B
C C
D

localhost:8888/notebooks/XB_26_SIYA [Link] 25/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [1]: 1 a=int(input("enter the no."))


2 for i in range(1,a+1):
3 for j in range(1,i+1):
4 print("*",end=" ")
5 print()
6 for k in range(a,1,-1):
7 for l in range(k,1,-1):
8 print("*",end=" ")
9 print()
10

enter the no.8


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

localhost:8888/notebooks/XB_26_SIYA [Link] 26/27


11/16/24, 10:54 AM XB_26_SIYA MALPANI - Jupyter Notebook

In [19]: 1 ​

In [ ]:
1 ​

localhost:8888/notebooks/XB_26_SIYA [Link] 27/27

You might also like