PSP Presentation
PSP Presentation
Datatypes
Classes:- Classes:-
Mapping/ Classes:- list, tuple,
Dictionary Int,float, string
Descripti Classes:- complex Description:-
on Set, Description:- Holds
Holds Data frozenset Holds collection of
In key Descriptio numeric value Items
value n:- Classes:-bool
Pair form Hold
Description:-
collection
of Holds either
Unique True or False
items
SEQUENCE DATA-TYPE
Types of Sequences:
3. Heterogeneous
Data
A single list can store items of different
data types
LIST () 4. Dynamic Size Lists can grow or shrink as needed,
without predefined limits
5. Duplicates Lists can contain duplicate elements
Allowed
LIST ()
In Python
Steps to create LIST
a In Python
To create a list in Python, Here's what a
we use square brackets list looks
([])and separate each like:
item with a comma.
Items in a list can be ListName =
any basic object type [ListItem,
found in Python, ListItem1,ListIt
including integers, em2,
strings, floating point
values or boolean ListItem3, ...]
values.
Steps to create LIST
a In Python
To create a list in Python, For example, to
we use square brackets create a list
([])and separate each named
item with a comma.
Items in a list can be “z” that holds the
any basic object type integers 3, 7, 4
found in Python, and 2,
including integers, you would write:
strings, floating point
values or boolean # Define a list
values.
Steps to create LIST
a In Python
The “z” list defined # Define a list
above has items that
are all of the same Heterogenous
type (integer or int), Elements =
but as mentioned, all
the items in a list do
[3, True,
not need to be of the 'Michael',
same type as you can 2.0]
see on the next page.
Range in Lists
LIST ()
The range() function generates a
sequence of numbers, which is often
used to create or manipulate lists.
LIST ()
range(n) creates list from numbers 0 to
n-1
example: numbers= list(range(10))
output: [1, 2, 3, 4, 5, 6, 7, 8, 9]
Comprehensions in Lists
LIST ()
List comprehensions provide a concise
way to create and manipulate lists. They
consist of an expression followed by a for
LIST () clause, optionally with additional if
clauses.
Syntax: [<expression> for <item> in <if
condition>]
Examples:
LIST ()
Lists with different Data Types
Lists in Python can hold items of different
data types, including integers, strings, floats,
LIST () Booleans, and even other lists or objects.
Examples:
mixed_list = [42, "hello", 3.14, True]
print(mixed_list) Output: [42, 'hello', 3.14,
True]
LIST ()
() specified
element in
the list.
a = [1, 3, 5, 7, 9]
LIST # Calculate the length of the
list
()
n = len(a)
-
CONCLUSION: ListPython lists are very flexible and can
LIST hold arbitrary data.Lists are a part of Python's syntax, so
() they do not need to be declared first.Lists can also be re-
sized quickly in a time-efficient manner. This is because
Python initializes some extra elements in the list at
initialization.Lists can hold heterogeneous
data.Mathematical functions cannot be directly applied to
lists. Instead, they have to be individually applied to each
element.Lists consume more memory as they are allocated
a few extra elements to allow for quicker appending of
items.
-
LIST ()
Thank You!
Team Members:
•Atharva Dixit - 24BCE10677
•Aastha Krishna - 24BCE10672
•Diva Chandra - 24BSA10066
•Sujal Bedarkar - 24BSA10304
•Keshav Sharma - 24BCE11506
We appreciate your time and
attention!