0% found this document useful (0 votes)
5 views40 pages

Python Class Basics and Data Types

The document contains a series of Python code snippets demonstrating various data types, operations, and control structures. It includes examples of arithmetic operations, data type definitions, conditional statements, loops, and error handling. The content serves as a practical guide for understanding basic Python programming concepts.

Uploaded by

faltu314159
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)
5 views40 pages

Python Class Basics and Data Types

The document contains a series of Python code snippets demonstrating various data types, operations, and control structures. It includes examples of arithmetic operations, data type definitions, conditional statements, loops, and error handling. The content serves as a practical guide for understanding basic Python programming concepts.

Uploaded by

faltu314159
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/14/25, 4:30 PM datacuration

In [2]: 2*2

Out[2]: 4

In [3]: #this a python class

In [4]: this

---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[4], line 1
----> 1 this

NameError: name 'this' is not defined

In [5]: #this
#is
#a
#pyhton class

In [6]: """this
is
a python class"""

Out[6]: 'this \nis \na python class'

In [7]: a=10

In [8]: type(a)

Out[8]: int

In [9]: b=10.0
type(b)

Out[9]: float

[Link] (1).html 1/40


11/14/25, 4:30 PM datacuration

In [10]: c=2+3i

Cell In[10], line 1


c=2+3i
^
SyntaxError: invalid decimal literal

In [11]: c=2+2j

In [12]: type(c)

Out[12]: complex

In [13]: a=True

In [14]: type(a)

Out[14]: bool

In [15]: s="welcome to nielit patna"

In [16]: type(s)

Out[16]: str

In [17]: l=[10,20,1,"sunil",20.5,[1,2,3]]

In [18]: t=(0,20,1,"sunil",20.5,[1,2,3])

In [19]: type(l)

Out[19]: list

In [20]: type(t)

Out[20]: tuple

[Link] (1).html 2/40


11/14/25, 4:30 PM datacuration

In [1]: s={10,12,13,1,2,3,4,1,2,2,2}

In [2]: s

Out[2]: {1, 2, 3, 4, 10, 12, 13}

In [3]: c=None

In [4]: type(c)

Out[4]: NoneType

In [5]: type(s)

Out[5]: set

In [6]: d={"Name":'Nielit',"roll no":12}

In [7]: d

Out[7]: {'Name': 'Nielit', 'roll no': 12}

In [8]: type(d)

Out[8]: dict

In [9]: d={"Name":'Nielit',"roll no":12,"roll no":25}

In [10]: d

Out[10]: {'Name': 'Nielit', 'roll no': 25}

In [11]: 2+2

Out[11]: 4

[Link] (1).html 3/40


11/14/25, 4:30 PM datacuration

In [12]: 2+2.3

Out[12]: 4.3

In [13]: 2*3

Out[13]: 6

In [14]: 2-3

Out[14]: -1

In [15]: 2/3

Out[15]: 0.6666666666666666

In [16]: 3/3

Out[16]: 1.0

In [17]: 10%3

Out[17]: 1

In [18]: 10/3

Out[18]: 3.3333333333333335

In [19]: 10//3

Out[19]: 3

In [20]: 2**3

Out[20]: 8

[Link] (1).html 4/40


11/14/25, 4:30 PM datacuration

In [21]: 10>20

Out[21]: False

In [22]: 10<20

Out[22]: True

In [23]: 10==20

Out[23]: False

In [24]: 10>=10

Out[24]: True

In [25]: 10!=20

Out[25]: True

In [26]: a=10

In [27]: a+=10 #a=a+10

In [28]: a

Out[28]: 20

In [29]: 10>20 and 20

Out[29]: False

In [30]: 20 and 10>20

Out[30]: False

In [32]: 20 and 10

[Link] (1).html 5/40


11/14/25, 4:30 PM datacuration

Out[32]: 10

In [33]: 20 or 10

Out[33]: 20

In [34]: a= 10

In [35]: b=not(a)

In [36]: b

Out[36]: False

In [37]: l=[10,20,1,200,13,9]

In [38]: s="welcome to nielit patna"

In [39]: 10 in l

Out[39]: True

In [40]: 9 not in l

Out[40]: False

In [41]: 'W' in s

Out[41]: False

In [42]: a=10

In [43]: b=20

In [44]: c=10

[Link] (1).html 6/40


11/14/25, 4:30 PM datacuration

In [45]: a is b

Out[45]: False

In [46]: d=20-10

In [47]: c is d

Out[47]: True

In [48]: id(a)

Out[48]: 140705341875608

In [49]: id(c)

Out[49]: 140705341875608

In [50]: id(b)

Out[50]: 140705341875928

In [51]: a=10-20/20+10*0

In [52]: a

Out[52]: 9.0

In [53]: a=input("Enter the 1st number")


b=input("enter the 2nd number")
sum=a+b
print(sum)

1020

In [54]: a=input("Enter the 1st number")


b=input("enter the 2nd number")

[Link] (1).html 7/40


11/14/25, 4:30 PM datacuration

sum=int(a)+int(b)
print(sum)

30

In [55]: a=int(input("Enter the 1st number"))


b=int(input("enter the 2nd number"))
sum=a+b
print(sum)

30

In [56]: a=int(input("Enter the 1st number"))


b=int(input("enter the 2nd number"))
sum=a+b
print(sum)

---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[56], line 1
----> 1 a=int(input("Enter the 1st number"))
2 b=int(input("enter the 2nd number"))
3 sum=a+b

ValueError: invalid literal for int() with base 10: '10.5'

In [57]: a=float(input("Enter the 1st number"))


b=float(input("enter the 2nd number"))
sum=a+b
print(sum)

30.5

In [58]: a=float(input("Enter the 1st number"))


b=float(input("enter the 2nd number"))
sum=a+b
print(sum)

[Link] (1).html 8/40


11/14/25, 4:30 PM datacuration

---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[58], line 1
----> 1 a=float(input("Enter the 1st number"))
2 b=float(input("enter the 2nd number"))
3 sum=a+b

ValueError: could not convert string to float: "'nielit'"

In [61]: a=eval(input("Enter the 1st number"))


b=eval(input("enter the 2nd number"))
sum=a+b
print(sum)

30.5

In [3]: amount=int(input("Enter the amount"))


if amount>100:
print("I will go to market")

In [5]: amount=int(input("Enter the amount"))


if amount>100:
print("I will go to market")
else:
print("i will not go to market")

i will not go to market

In [8]: marks=eval(input("Enter your percentage marks"))


if marks>=60:
print("1st div")
if marks>=45 and marks<60:
print("2nd div")
if marks>=33 and marks<45:
print("3rd div")
if marks<33:
print("fail")

fail

[Link] (1).html 9/40


11/14/25, 4:30 PM datacuration

In [9]: marks=eval(input("Enter your percentage marks"))


if marks>=60:
print("1st div")
if marks>=45:
print("2nd div")
if marks>=33:
print("3rd div")
else:
print("fail")

1st div
2nd div
3rd div

In [10]: marks=eval(input("Enter your percentage marks"))


if marks>=60:
print("1st div")
if marks>=45:
print("2nd div")
if marks>=33:
print("3rd div")
else:
print("fail")

fail

In [14]: marks=eval(input("Enter your percentage marks"))


if marks>=60:
print("1st div")
elif marks>=45:
print("2nd div")
elif marks>=33:
print("3rd div")
else:
print("fail")

fail

In [15]: print("Nielit")
print("Nielit")
print("Nielit")

[Link] (1).html 10/40


11/14/25, 4:30 PM datacuration

print("Nielit")
print("Nielit")

Nielit
Nielit
Nielit
Nielit
Nielit

In [16]: for i in range(5):


print(i)

0
1
2
3
4

In [19]: for i in range(1,11):


print(i)

1
2
3
4
5
6
7
8
9
10

In [21]: for i in range(2,11,2):


print(i)

2
4
6
8
10

[Link] (1).html 11/40


11/14/25, 4:30 PM datacuration

In [22]: for i in range(1,11):


if i%2==0:
print(i)

2
4
6
8
10

In [23]: l=[10,20,30,40,50,60]
for i in l:
print(i)

10
20
30
40
50
60

In [24]: l=[10,20,30,40,50,60]
for i in l:
print(l)

[10, 20, 30, 40, 50, 60]


[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60]

In [25]: a=1
while a<10:
print(a)
a=a+1

[Link] (1).html 12/40


11/14/25, 4:30 PM datacuration

1
2
3
4
5
6
7
8
9

In [26]: for i in range(11):


if i==7:
continue
print(i)

0
1
2
3
4
5
6
8
9
10

In [27]: for i in range(11):


if i==7:
break
print(i)

0
1
2
3
4
5
6

In [28]: for i in range(5):


for j in range(5):

[Link] (1).html 13/40


11/14/25, 4:30 PM datacuration

print('*')

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

In [29]: for i in range(5):


for j in range(5):
print('*')
print()

[Link] (1).html 14/40


11/14/25, 4:30 PM datacuration

*
*
*
*
*

*
*
*
*
*

*
*
*
*
*

*
*
*
*
*

*
*
*
*
*

In [30]: for i in range(5):


for j in range(5):
print('*',end=" ")
print()

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

[Link] (1).html 15/40


11/14/25, 4:30 PM datacuration

In [1]: for i in range(1,6):


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

1
1 2
1 2 3
1 2 3 4

In [1]: l=[1,2,3,4,[10,20,30,40],"Welcome",1.5,1.3,1.5]

In [2]: l[0]

Out[2]: 1

In [3]: l[5]

Out[3]: 'Welcome'

In [4]: len(l)

Out[4]: 9

In [5]: l[9]

---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Cell In[5], line 1
----> 1 l[9]

IndexError: list index out of range

In [6]: l[8]

Out[6]: 1.5

In [7]: l[-1]

[Link] (1).html 16/40


11/14/25, 4:30 PM datacuration

Out[7]: 1.5

In [8]: l

Out[8]: [1, 2, 3, 4, [10, 20, 30, 40], 'Welcome', 1.5, 1.3, 1.5]

In [9]: l[4]

Out[9]: [10, 20, 30, 40]

In [10]: l[4][1]

Out[10]: 20

In [11]: l[4][1]=200

In [12]: l

Out[12]: [1, 2, 3, 4, [10, 200, 30, 40], 'Welcome', 1.5, 1.3, 1.5]

In [13]: for i in l:
print(i)

1
2
3
4
[10, 200, 30, 40]
Welcome
1.5
1.3
1.5

In [15]: for i in range(len(l)):


print(l[i])

[Link] (1).html 17/40


11/14/25, 4:30 PM datacuration

1
2
3
4
[10, 200, 30, 40]
Welcome
1.5
1.3
1.5

In [16]: l[:]

Out[16]: [1, 2, 3, 4, [10, 200, 30, 40], 'Welcome', 1.5, 1.3, 1.5]

In [17]: l[:5]

Out[17]: [1, 2, 3, 4, [10, 200, 30, 40]]

In [18]: l[2:5]

Out[18]: [3, 4, [10, 200, 30, 40]]

In [19]: l[::2]

Out[19]: [1, 3, [10, 200, 30, 40], 1.5, 1.5]

In [20]: s="Welcome"

In [21]: s[::-1]

Out[21]: 'emocleW'

In [22]: l1=[1,2,3,4]
l2=[10,20,30,40]

In [23]: l1+l2

Out[23]: [1, 2, 3, 4, 10, 20, 30, 40]

[Link] (1).html 18/40


11/14/25, 4:30 PM datacuration

In [24]: l1*l2

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[24], line 1
----> 1 l1*l2

TypeError: can't multiply sequence by non-int of type 'list'

In [25]: l

Out[25]: [1, 2, 3, 4, [10, 200, 30, 40], 'Welcome', 1.5, 1.3, 1.5]

In [26]: l1*4

Out[26]: [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]

In [27]: 1 in l

Out[27]: True

In [28]: s

Out[28]: 'Welcome'

In [29]: l4=list(s)

In [30]: l4

Out[30]: ['W', 'e', 'l', 'c', 'o', 'm', 'e']

In [31]: l

Out[31]: [1, 2, 3, 4, [10, 200, 30, 40], 'Welcome', 1.5, 1.3, 1.5]

In [32]: [Link](500)

[Link] (1).html 19/40


11/14/25, 4:30 PM datacuration

In [33]: l

Out[33]: [1, 2, 3, 4, [10, 200, 30, 40], 'Welcome', 1.5, 1.3, 1.5, 500]

In [35]: l5=[]
for i in range(7):
num=int(input("enter the number"))
[Link](num)

print(l5)

[1, 2, 3, 4, 5, 6, 7]

In [36]: l5

Out[36]: [1, 2, 3, 4, 5, 6, 7]

In [37]: l

Out[37]: [1, 2, 3, 4, [10, 200, 30, 40], 'Welcome', 1.5, 1.3, 1.5, 500]

In [38]: [Link](l5)

In [39]: l

[Link] (1).html 20/40


11/14/25, 4:30 PM datacuration

Out[39]: [1,
2,
3,
4,
[10, 200, 30, 40],
'Welcome',
1.5,
1.3,
1.5,
500,
1,
2,
3,
4,
5,
6,
7]

In [40]: [Link](2,2000)

In [41]: l

Out[41]: [1,
2,
2000,
3,
4,
[10, 200, 30, 40],
'Welcome',
1.5,
1.3,
1.5,
500,
1,
2,
3,
4,
5,
6,
7]

[Link] (1).html 21/40


11/14/25, 4:30 PM datacuration

In [42]: [Link](2000)

In [43]: l

Out[43]: [1,
2,
3,
4,
[10, 200, 30, 40],
'Welcome',
1.5,
1.3,
1.5,
500,
1,
2,
3,
4,
5,
6,
7]

In [44]: [Link]()

Out[44]: 7

In [45]: [Link](7)

Out[45]: 1.3

In [46]: min(l)

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[46], line 1
----> 1 min(l)

TypeError: '<' not supported between instances of 'list' and 'int'

[Link] (1).html 22/40


11/14/25, 4:30 PM datacuration

In [47]: min(l5)

Out[47]: 1

In [48]: l5

Out[48]: [1, 2, 3, 4, 5, 6, 7]

In [49]: l6=l5

In [50]: l6

Out[50]: [1, 2, 3, 4, 5, 6, 7]

In [51]: l6[5]=500

In [52]: l6

Out[52]: [1, 2, 3, 4, 5, 500, 7]

In [53]: l5

Out[53]: [1, 2, 3, 4, 5, 500, 7]

In [54]: l6=l5[:]

In [57]: l6

Out[57]: [1, 2, 3, 4, 5, 500, 7]

In [58]: l6[5]=6

In [59]: l6

Out[59]: [1, 2, 3, 4, 5, 6, 7]

[Link] (1).html 23/40


11/14/25, 4:30 PM datacuration

In [60]: l5

Out[60]: [1, 2, 3, 4, 5, 500, 7]

In [61]: l7=list(l5)

In [62]: l7

Out[62]: [1, 2, 3, 4, 5, 500, 7]

In [63]: l7[5]=6

In [64]: l7

Out[64]: [1, 2, 3, 4, 5, 6, 7]

In [1]: t=(1,2,3,4,5,(10,20,30))

In [2]: type(t)

Out[2]: tuple

In [3]: t[4]

Out[3]: 5

In [9]: t[5][0]

Out[9]: 10

In [5]: len(t)

Out[5]: 6

In [6]: t=(1,2,3,4,5,[10,20,30])

[Link] (1).html 24/40


11/14/25, 4:30 PM datacuration

In [8]: t[5][0]

Out[8]: 10

In [10]: for i in range(len(t)):


print(t[i])

1
2
3
4
5
[10, 20, 30]

In [11]: t[2]=100

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[11], line 1
----> 1 t[2]=100

TypeError: 'tuple' object does not support item assignment

In [12]: t+t

Out[12]: (1, 2, 3, 4, 5, [10, 20, 30], 1, 2, 3, 4, 5, [10, 20, 30])

In [13]: [Link](6)

---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[13], line 1
----> 1 [Link](6)

AttributeError: 'tuple' object has no attribute 'append'

In [14]: t+(6,)

Out[14]: (1, 2, 3, 4, 5, [10, 20, 30], 6)

[Link] (1).html 25/40


11/14/25, 4:30 PM datacuration

In [15]: t[1:4]

Out[15]: (2, 3, 4)

In [16]: t[::2]

Out[16]: (1, 3, 5)

In [17]: t

Out[17]: (1, 2, 3, 4, 5, [10, 20, 30])

In [18]: [Link](4)

Out[18]: 1

In [19]: [Link](6)

Out[19]: 0

In [20]: [Link](4)

Out[20]: 3

In [21]: len(t)

Out[21]: 6

In [22]: a=20
b=30
a,b=b,a
print(a)
print(b)

30
20

In [23]: s="Welcome to Nielit Patna"

[Link] (1).html 26/40


11/14/25, 4:30 PM datacuration

In [24]: type(s)

Out[24]: str

In [25]: s[1]

Out[25]: 'e'

In [26]: s[1]='E'

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[26], line 1
----> 1 s[1]='E'

TypeError: 'str' object does not support item assignment

In [27]: a=20

In [28]: a=30

In [29]: for i in s:
print(i)

[Link] (1).html 27/40


11/14/25, 4:30 PM datacuration

W
e
l
c
o
m
e

t
o

N
i
e
l
i
t

P
a
t
n
a

In [31]: for i in range(len(s)):


print(s[i])

[Link] (1).html 28/40


11/14/25, 4:30 PM datacuration

W
e
l
c
o
m
e

t
o

N
i
e
l
i
t

P
a
t
n
a

In [32]: s[0:7]

Out[32]: 'Welcome'

In [33]: s[::-1]

Out[33]: 'antaP tileiN ot emocleW'

In [34]: 'w' in s

Out[34]: False

In [35]: s1='welcome to Nielit Patna'

In [36]: s is s1

[Link] (1).html 29/40


11/14/25, 4:30 PM datacuration

Out[36]: False

In [42]: s2="Welcome to Nielit Patna"

In [43]: s is s2

Out[43]: False

In [44]: s2 is s

Out[44]: False

In [45]: s

Out[45]: 'Welcome to Nielit Patna'

In [46]: s+s2

Out[46]: 'Welcome to Nielit PatnaWelcome to Nielit Patna'

In [47]: s*3

Out[47]: 'Welcome to Nielit PatnaWelcome to Nielit PatnaWelcome to Nielit Patna'

In [48]: s

Out[48]: 'Welcome to Nielit Patna'

In [51]: s5=[Link]('W','w')

In [50]: s

Out[50]: 'Welcome to Nielit Patna'

In [52]: s5

Out[52]: 'welcome to Nielit Patna'

[Link] (1).html 30/40


11/14/25, 4:30 PM datacuration

In [53]: _

Out[53]: 'welcome to Nielit Patna'

In [1]: d={"Name":'deepraj',"roll no":25,"program":"MCA"}

In [2]: d['Name']

Out[2]: 'deepraj'

In [3]: d['roll no']

Out[3]: 25

In [4]: d['Nmae']='suraj'

In [5]: d

Out[5]: {'Name': 'deepraj', 'roll no': 25, 'program': 'MCA', 'Nmae': 'suraj'}

In [6]: d['Name']='Mohit'

In [7]: d

Out[7]: {'Name': 'Mohit', 'roll no': 25, 'program': 'MCA', 'Nmae': 'suraj'}

In [8]: d1={"Name":'deepraj',"roll no":25,"program":"MCA","Name":'Suraj'}

In [9]: d1

Out[9]: {'Name': 'Suraj', 'roll no': 25, 'program': 'MCA'}

In [10]: d['same']

[Link] (1).html 31/40


11/14/25, 4:30 PM datacuration

---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[10], line 1
----> 1 d['same']

KeyError: 'same'

In [11]: for i in d:
print(i)

Name
roll no
program
Nmae

In [12]: for i in [Link]():


print(i)

('Name', 'Mohit')
('roll no', 25)
('program', 'MCA')
('Nmae', 'suraj')

In [13]: for key ,value in [Link]():


print(key,":",value)

Name : Mohit
roll no : 25
program : MCA
Nmae : suraj

In [14]: pair1 = [('Mohan',95),('Ram',89),('Suhel',92),('Sangeeta',85)]

In [15]: dict(pair1)

Out[15]: {'Mohan': 95, 'Ram': 89, 'Suhel': 92, 'Sangeeta': 85}

In [16]: def functionname():


print('Welcome to nielit')

[Link] (1).html 32/40


11/14/25, 4:30 PM datacuration

In [17]: functionname()

Welcome to nielit

In [18]: functionname()

Welcome to nielit

In [19]: len(d)

Out[19]: 4

In [20]: def add():


a=int(input("Enter 1st No."))
b=int(input("Enter 2nd No."))
sum=a+b
print(sum)

In [21]: add()

30

In [22]: def add1(a,b):

sum=a+b
print(sum)

In [23]: add1(10,30)

40

In [24]: c=add1(10,20)

30

In [26]: print(c)

None

In [27]: def add1(a,b):


sum=a+b

[Link] (1).html 33/40


11/14/25, 4:30 PM datacuration

return sum

In [29]: print(add1(2,3))

In [30]: c=add1(2,3)

In [31]: print(c)

In [32]: def add2(a,b,c):


sum=a+b+c
return sum

In [33]: add2(1,2,3)

Out[33]: 6

In [34]: add2(2,3)

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[34], line 1
----> 1 add2(2,3)

TypeError: add2() missing 1 required positional argument: 'c'

In [35]: def add2(a,b,c=0):


sum=a+b+c
return sum

In [36]: add2(2,3)

Out[36]: 5

In [39]: add2(2,3,4)

[Link] (1).html 34/40


11/14/25, 4:30 PM datacuration

Out[39]: 9

In [41]: def add2(a,b,c=9):


sum=a+b+c
return sum

In [42]: add2(2,3)

Out[42]: 14

In [43]: def add2(a=0,b,c):


sum=a+b+c
return sum

Cell In[43], line 1


def add2(a=0,b,c):
^
SyntaxError: parameter without a default follows parameter with a default

In [44]: def add2(a=0,b=0,c=0):


sum=a+b+c
return sum

In [45]: add2()

Out[45]: 0

In [46]: add2(1)

Out[46]: 1

In [47]: add2(2,3)

Out[47]: 5

In [48]: add2(2,3,4)

Out[48]: 9

[Link] (1).html 35/40


11/14/25, 4:30 PM datacuration

In [49]: add2(2,3,4,5)

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[49], line 1
----> 1 add2(2,3,4,5)

TypeError: add2() takes from 0 to 3 positional arguments but 4 were given

In [60]: a1=10
def add():
a1=20
b1=30
print(a1+b1)

print(a1)
add()

10
50

In [1]: def add1(a,b,c):


return a+b+c

In [2]: add1(2,3,4)

Out[2]: 9

In [3]: def add2(*arg):


sum=0
for i in arg:
sum=sum+i
return sum

In [4]: add2(1)

Out[4]: 1

In [5]: add2(1,2)

[Link] (1).html 36/40


11/14/25, 4:30 PM datacuration

Out[5]: 3

In [6]: add2(2,3,4,5)

Out[6]: 14

In [7]: def fun(**kwarg):


for i,j in [Link]():
print(i,"=",j)

In [8]: fun(a=10,b=20,d=30,c=40)

a = 10
b = 20
d = 30
c = 40

In [9]: d=lambda x:x**2

In [10]: d(2)

Out[10]: 4

In [11]: d(3)

Out[11]: 9

In [12]: d1=lambda a,b: a+b

In [13]: d1(2,3)

Out[13]: 5

In [16]: l=[1,2,3,4]

square=map(lambda x:x**2,l)
square_list=list(square)
print(square_list)

[Link] (1).html 37/40


11/14/25, 4:30 PM datacuration

[1, 4, 9, 16]

In [24]: def is_even():


if n%2==0:
return True
l=[1,2,3,4,5,6,7]
d=filter((is_even(),l))
e=list(d)
print(e)

---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[24], line 5
3 return True
4 l=[1,2,3,4,5,6,7]
----> 5 d=filter((is_even(),l))
6 e=list(d)
7 print(e)

Cell In[24], line 2, in is_even()


1 def is_even():
----> 2 if n%2==0:
3 return True

NameError: name 'n' is not defined

In [25]: import math

In [26]: [Link](4)

Out[26]: 2.0

In [27]: mul(2,3)

---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[27], line 1
----> 1 mul(2,3)

NameError: name 'mul' is not defined

[Link] (1).html 38/40


11/14/25, 4:30 PM datacuration

In [28]: import MCA

In [29]: mul(2,3)

---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[29], line 1
----> 1 mul(2,3)

NameError: name 'mul' is not defined

In [30]: [Link](2,3)

Out[30]: 6

In [31]: [Link](3,2)

Out[31]: 5

In [32]: from MCA import add

In [33]: add(3,4)

Out[33]: 7

In [34]: import numpy as np

In [35]: arr1=[Link]([1,2,3,4,5])

In [37]: print(type(arr1))

<class '[Link]'>

In [38]: l=[10,20,30,40]
arr2=[Link](l)

In [39]: arr2

[Link] (1).html 39/40


11/14/25, 4:30 PM datacuration

Out[39]: array([10, 20, 30, 40])

In [41]: [Link]

Out[41]: (4,)

In [42]: [Link]

Out[42]: 1

In [43]: [Link]

Out[43]: 4

In [44]: arr3=[Link]([[1,2,3],[4,5,6]])

In [45]: arr3

Out[45]: array([[1, 2, 3],


[4, 5, 6]])

In [46]: [Link]

Out[46]: (2, 3)

In [47]: [Link]

Out[47]: 2

In [ ]:

[Link] (1).html 40/40

You might also like