I am leaving a pole to know your interest then I will start guiding the research paper writing
Types of data structure in python are
Tuple, List , Dictionary, and set
Touples are ordered collection of different elements in round braces () and are immutable( not changeable)
For example
Tup1=> (1,’a’, True)
1- Integer, a is string, True is loigical
Tuples are stored in order
##python
Tup1 = (1,’a’, true, 2+3i, 3.14 )
## check the type
Type(Tup1) (shift +Enter)
Tuple
To get first element
Tup1[0] => will give fiorst element
To get the last element we type in jupyter /colab
Tup1[-1] shift+enter
If we type
Tup1[0:2]
We get two elements , if any element in in “ ” it will be exclusive and not come in output
Immutable
If we want to assign any other value to tuple
Tup1[0] = “hello”
Then error will appear
Example of jupyter/colab
Tuple1[1] = “ this is game”
Error
Want to know the length of tuple then write
# len(Tup1)
Adding two tuple(concatenating or join
Tup1+tup2
Suppose tup1 =(1,2)
Tup2 =(3,4)
Tup1+tup2 =(1,2,3,4)
If we write tup2+tup1 then we will gate
(3,4,1,2)
To repeat the elements in we will multiply the number of required repetition
Ex
Tup1*3 will give=> (1,2, 1,2., 1,2)
We can join this new outcome with tup2
Tup1*3 +tup2
We will get (1,2, 1,2., 1,2, 3,4)
# to know the maximum and minimum value we
Min(tup1)
Max(tup1)
List function
List are mutable and it is written in [] square bracket
Starting the List command
#l1 =[ 1,’sparta’, 3.14,True]
L1 shift+enter
Type(l1)
List
Extracting the elements
Write l1[0] => give first element
If we want to get the lists of elements from Sparta to true
We write l1[1:3] will give two elements [‘sparta’, 3.14]
To change the element like first element write l1[0] =100
Thene new l1 =[100, ’sparta’, 3.14,True]
# suppose we have l2 = [1,”a”,2,”b”,3, “c”] and we want to add one more element like gas we will use append method
As l2.append(“gas”)
The outcome will be [1,”a”,2,”b”,3, “c”, ‘gas’]
Popping out last element (removal)
L1.pop()
L1 [1,”a”,2,”b”,3, “c”]
Last element removed
Reversing the list of the elements
L1.reverse()
All the elemnts will reversed
[“c”, 3, “b”,2,”a”,1]
Suppose we want to insert an element in the list we will use
L1.insert(1,”Gas”)
L1
[1, ‘Gas’, ”a”,2,”b”, 3,”c”]
Sorting
L1 = [“mango”, “grapes”, “banana”, “apple”]
Type l1.sort() => will give alphabetical order
L1
[“apple”,”banana”,”grapes”,”mango”]
Cocatenate the list
L1+l2
L2 = [1,2,3]
L1+L2 = [“mango”, “grapes”, “banana”, “apple”,1,2,3]
To repeat the element we will use * and followed by the number to repeat
As l2*2 = [1,2,3,1,2,3]
Tuple, List , Dictionary, and set
Touples are ordered collection of different elements in round braces () and are immutable( not changeable)
For example
Tup1=> (1,’a’, True)
1- Integer, a is string, True is loigical
Tuples are stored in order
##python
Tup1 = (1,’a’, true, 2+3i, 3.14 )
## check the type
Type(Tup1) (shift +Enter)
Tuple
To get first element
Tup1[0] => will give fiorst element
To get the last element we type in jupyter /colab
Tup1[-1] shift+enter
If we type
Tup1[0:2]
We get two elements , if any element in in “ ” it will be exclusive and not come in output
Immutable
If we want to assign any other value to tuple
Tup1[0] = “hello”
Then error will appear
Example of jupyter/colab
Tuple1[1] = “ this is game”
Error
Want to know the length of tuple then write
# len(Tup1)
Adding two tuple(concatenating or join
Tup1+tup2
Suppose tup1 =(1,2)
Tup2 =(3,4)
Tup1+tup2 =(1,2,3,4)
If we write tup2+tup1 then we will gate
(3,4,1,2)
To repeat the elements in we will multiply the number of required repetition
Ex
Tup1*3 will give=> (1,2, 1,2., 1,2)
We can join this new outcome with tup2
Tup1*3 +tup2
We will get (1,2, 1,2., 1,2, 3,4)
# to know the maximum and minimum value we
Min(tup1)
Max(tup1)
List function
List are mutable and it is written in [] square bracket
Starting the List command
#l1 =[ 1,’sparta’, 3.14,True]
L1 shift+enter
Type(l1)
List
Extracting the elements
Write l1[0] => give first element
If we want to get the lists of elements from Sparta to true
We write l1[1:3] will give two elements [‘sparta’, 3.14]
To change the element like first element write l1[0] =100
Thene new l1 =[100, ’sparta’, 3.14,True]
# suppose we have l2 = [1,”a”,2,”b”,3, “c”] and we want to add one more element like gas we will use append method
As l2.append(“gas”)
The outcome will be [1,”a”,2,”b”,3, “c”, ‘gas’]
Popping out last element (removal)
L1.pop()
L1 [1,”a”,2,”b”,3, “c”]
Last element removed
Reversing the list of the elements
L1.reverse()
All the elemnts will reversed
[“c”, 3, “b”,2,”a”,1]
Suppose we want to insert an element in the list we will use
L1.insert(1,”Gas”)
L1
[1, ‘Gas’, ”a”,2,”b”, 3,”c”]
Sorting
L1 = [“mango”, “grapes”, “banana”, “apple”]
Type l1.sort() => will give alphabetical order
L1
[“apple”,”banana”,”grapes”,”mango”]
Cocatenate the list
L1+l2
L2 = [1,2,3]
L1+L2 = [“mango”, “grapes”, “banana”, “apple”,1,2,3]
To repeat the element we will use * and followed by the number to repeat
As l2*2 = [1,2,3,1,2,3]
Conditional statement in Python
Blueprint(pseudocode)
If(condition){
Statement to be executed..
}
Else{
Statement to be executed
}
Simple if statement in python
Assign values to two variables
A = 10
B = 20
If b>a:
--Print(“B is greater than A”) press shift+enter
-- is said indent space required to run if statement
--
If we type
If a>b:
Print(“B is greater then A”)
Nothing will appear
Modified
If a>b:
Print(“A is greater then B”)
else:
print(“B is greater than A”)
%%%%%
Now taking three variables
a =10
b =20
c= 30
--
If(a>b) & (a>c)
Print(“A is greatest”)
Elif(b>a) &(b>c):
Print(“b is greatest”)
Else:
Print(“c is the greatest”)
--
# If with tuple
Tup1 = (‘a’, ‘b’, ‘c’)
If ‘a’ in tup1:
Print(“value a is present in tup1”) shift+enter
--
Tup1 = (‘a’, ‘b’, ‘c’)
If ‘z’ in tup1:
Print(“value a is present in tup1”)
Else:
Print(“value z is not present in tup1”)
If statement with list
l1 = {‘a’, ‘b’, ‘c’)
if l1[1] == ‘b’:
l[1] =’z’
output
{‘a’,’z’,’c’}
If with dictionary
D1 = {‘k1’:10, ‘k2’:20, ‘k3’:30}
If d1[‘k3’] ==30:
D1[‘k3’] =d1[‘k3’]+100## adding 100 in the key 3
Looping statement is used to repeat the task many time
The loops are
For and while
While loop
i=1
while i<=10:
print(i)
i =i+1
shift enter
result will 1,2,…10
table of 2
i =1
n=2
while i<=10:
print(n,” * “, i, “=”, n*i)
i =i+1
--
# while loop with list
l1 = [12,3,45,6]
i =0
while i <len(l1):
l1[i] = l1[i]+100
i = i+100
--
l1
--
Blueprint(pseudocode)
If(condition){
Statement to be executed..
}
Else{
Statement to be executed
}
Simple if statement in python
Assign values to two variables
A = 10
B = 20
If b>a:
--Print(“B is greater than A”) press shift+enter
-- is said indent space required to run if statement
--
If we type
If a>b:
Print(“B is greater then A”)
Nothing will appear
Modified
If a>b:
Print(“A is greater then B”)
else:
print(“B is greater than A”)
%%%%%
Now taking three variables
a =10
b =20
c= 30
--
If(a>b) & (a>c)
Print(“A is greatest”)
Elif(b>a) &(b>c):
Print(“b is greatest”)
Else:
Print(“c is the greatest”)
--
# If with tuple
Tup1 = (‘a’, ‘b’, ‘c’)
If ‘a’ in tup1:
Print(“value a is present in tup1”) shift+enter
--
Tup1 = (‘a’, ‘b’, ‘c’)
If ‘z’ in tup1:
Print(“value a is present in tup1”)
Else:
Print(“value z is not present in tup1”)
If statement with list
l1 = {‘a’, ‘b’, ‘c’)
if l1[1] == ‘b’:
l[1] =’z’
output
{‘a’,’z’,’c’}
If with dictionary
D1 = {‘k1’:10, ‘k2’:20, ‘k3’:30}
If d1[‘k3’] ==30:
D1[‘k3’] =d1[‘k3’]+100## adding 100 in the key 3
Looping statement is used to repeat the task many time
The loops are
For and while
While loop
i=1
while i<=10:
print(i)
i =i+1
shift enter
result will 1,2,…10
table of 2
i =1
n=2
while i<=10:
print(n,” * “, i, “=”, n*i)
i =i+1
--
# while loop with list
l1 = [12,3,45,6]
i =0
while i <len(l1):
l1[i] = l1[i]+100
i = i+100
--
l1
--
if you know basic coding then performing in Data Science become easy
Koun se subject par lecture chahiye?
Anonymous Poll
61%
Statistics
52%
Machine Learning
16%
Linear Algebra
10%
Thesis writing