Created 3 years ago
Bootcamp Python Week 2 - Hands-on session on Data Structures
Data Types & Data Structures
-
Built-in(Primitive) data types:
Integer, Floating point, String, Boolean Values -
Additional data structures(Non-Primitive):
Lists, Dictionary, Sets & Tuples
# Converting a nested list to a set
L = ["aa",123,[1,2]]
set(L)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-39304780bc15> in <module>
1 L = ["aa",123,[1,2]]
----> 2 set(L)
TypeError: unhashable type: 'list'
# 1. How will you get odd numbers from this list?
a = [1,2,3,4,5,6,7,8,9,0] # fixed list
# List slicing
a[::2]
[1, 3, 5, 7, 9]