0% found this document useful (0 votes)
3 views13 pages

While Loop Set

The document provides an overview of various Python programming concepts including while loops, tuples, dictionaries, sets, and list comprehensions. It explains the characteristics and functions associated with each data structure, as well as the syntax for defining and calling functions. Additionally, it includes examples of list comprehensions for generating new lists based on existing data.

Uploaded by

infaiics20
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)
3 views13 pages

While Loop Set

The document provides an overview of various Python programming concepts including while loops, tuples, dictionaries, sets, and list comprehensions. It explains the characteristics and functions associated with each data structure, as well as the syntax for defining and calling functions. Additionally, it includes examples of list comprehensions for generating new lists based on existing data.

Uploaded by

infaiics20
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

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

You might also like