Python Learning
Kanalga Telegramβda oβtish
Python learning resources Beginner to advanced Python guides, cheatsheets, books and projects. For data science, backend and automation. Join π https://rebrand.ly/bigdatachannels DMCA: @disclosure_bds Contact: @mldatascientist
Ko'proq ko'rsatish5 724
Obunachilar
-324 soatlar
-117 kun
-1730 kun
Postlar arxiv
5 724
Deleting Tuples
Tuples are immutable and cannot be deleted. You cannot delete or remove items from a tuple. But deleting tuple entirely is possible by using the keyword
delSlicing of Tuple
To fetch specific sets of sub-elements from tuple or list, we use this unique function called slicing. Slicing is not only applicable to tuple but also for array and list.
x = ("a", "b","c", "d", "e")
print(x[2:4])
The output of this code will be (βcβ, βdβ).
π Read Online
#Python #python_3
βββββββββββββ
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group5 724
Learn R and Python Programming for Data Visualization
From Raw Data to Insightful Narratives: Creating Visual Charts
β° Free Online Course
π¬ video lessons
Rating βοΈ: 4.6 out 5
Students π¨βπ : 2,300
Duration β° : 1hr 56min of on-demand video
Created by π¨βπ«: Pranjal Srivastava, Harshit Srivastava
π COURSE LINK
#python #programming #R
ββββββββββββββ
πJoin @python_bds for moreπ
5 724
Using tuples as keys in dictionaries
Since tuples are hashable, and list is not, we must use tuple as the key if we need to create a composite key to use in a dictionary.
Example: We would come across a composite key if we need to create a telephone directory that maps, first-name, last-name, pairs of telephone numbers, etc. Assuming that we have declared the variables as last and first number, we could write a dictionary assignment statement as shown below:
directory[last,first] = numberInside the brackets, the expression is a tuple. We could use tuple assignment in a for loop to navigate this dictionary.
for last, first in directory: print first, last, directory[last, first]This loop navigates the keys in the directory, which are tuples. It assigns the elements of each tuple to last and first and then prints the name and corresponding telephone number. Tuples and dictionary Dictionary can return the list of tuples by calling items, where each tuple is a key value pair.
a = {'x':100, 'y':200}
b = list(a.items())
print(b)
π Read Online
#Python #python_3
βββββββββββββ
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group