While Loop
.
While Loop
A while loop in Python is
used to execute a block of
statements repeatedly until
a given condition is satisfied.
Tuple
[Link]
[Link] by comma
3. Declare by using ()
Functions of Tuple
1. index()
2. count()
Dictionary
[Link]
[Link] by {}
[Link] keys are not allowed, values are allowed
Dictionaries
Keys and values in dictionary
[Link]() : Returns all keys of dictionaries
[Link]() : Returns all values of a dictionaries
[Link]() : return key and value pairs of a dictionary
[Link](): Update the dictionary
[Link](‘key’): To remove the element from dictionary
Set
1. Mutable
2. Unordered
3. Duplicates are not allowed
4. Sets are enclosed by {}
Function of ‘Set
1. update
2. Union
3. intersection
4. difference
List comprehension
List comprehension is a concise way to create lists in Python based on existing
lists, iterable objects, or conditions. It allows you to generate a new list by
applying an expression or transformation to each element of the existing list
List Comprehension
[i for i in range(10)] finding even numbers
[i for i in list if i%2==0]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[i*i for i in range(10)]
Squaring above list
[0,1,4,9,16,25,36,49,64,81]
[i**2 for i in range(10)]
Introduction to Function
def fun_name(parameters):
A function is a named block statement1
of reusable code that statement2
performs a specific task
my_function() # Function calling
Thank you