Difference Between List, Tuple, Set and Dictionary in Python

preview_player
Показать описание
This Tutorials explains the difference between List, Tuple, Set and Dictionary in Python

# DIFFERENCE BETWEEN
# LIST - square braces
# TUPLE - rounded braces
# SET - The set keyword
# DICTIONARY - curly braces: made up of key-value pairs

list1 = ["Computer", "Printer", "TV", "Camera", 89, 30.8]

tuple1 = ("Computer", "Printer", "TV", "Camera", 89, 30.8)

set1 = set(["Computer", "Printer", "TV", "Camera", 89, 30.8])
dict1 = {
1: "Monday",
2: "Tuesday",
3: "Wednesday"
}

Written explanation here:

Рекомендации по теме
Комментарии
Автор

Hi guys, thanks for being there! You could support my channel by buying me a coffee buymeacoff.ee/PWsXo7h13

KindsonTheTechPro
Автор

I was looking for a concise video to explain all these 4 concepts and stumbled on this. I have used all concepts before and needed clarification but I think this content needs to be updated.

1. Sets can be created using {} without the need for the 'set' keyword. E.g., set1 = { 'a', 'b', 1 }
2. Dictionaries can be created using the same curly braces '{}' but will only be considered to be a dictionary if and only if it takes in keys and values, which is quite obvious.
3. The other way to make a list or a tuple or a set or a dictionary is by using their keywords. E.g., list(), tuple(), set(), dict().

I just thought to point this out. Hope it helps!

Kemmydai
Автор

we can define set using {}, what you used is type caset.
for eg:
set1={"apple", "baanana", "orrange"}
print(set1)
print(type(set1))

prabuchandrasekar
Автор

Thank u I understood . Tomorrow is my computer science finals 😂

bhavishyapancholi
Автор

This was really helpful and I understood everything. Thank you!

MalPlayss
Автор

Starting my data science in a weeks time and was looking for the explanation of
1:list
2:Tuple
3:Set and dictionary and I found out that this is a perfect one - easy to understand

findlostphone
Автор

Good explanation,
Adding my further understanding where to use them;

List:

Used in JSON format

Useful for Array operations

Used in Databases

Tuple:

Used to insert records in the database through SQL query at a time.Ex: (1.’sravan’, 34).(2.’geek’, 35)

Used in parentheses checker

Set:

Finding unique elements

Join operations

Dictionary:

Used to create a data frame with lists

Used in JSON

AK-Star
Автор

Thank you - I wish you would explain WHY you would use dictionary vs set

wiredupjax
Автор

Perfect Explanation of these four! Thanks Bro!

applymarket
Автор

Sir you mentioned that you need to use the keyword "set" to create a set. But it is not necessary, all you have to do is to enclose the data in curly braces. Eg: a={ 1, 2, 3}


If you need to create a dictionary then just add a key to the above set.
Eg: a={ "first" : 1, "second" : 2 }

ramprakash
Автор

Good intro to these Python topics. Thanks.

JJJJ-gluf
Автор

awesome thank you so much, its really helpful

RGMUTEX
Автор

And set can be directly mentioned with {} instead of set ([])

anirudhani
Автор

thankyou sir you are very much life saver you explain very well i have subscribed

Repentforthekindomogiah
Автор

Kindson bro, curly braces can be used to define set try This > set1={'a', 'b', 'c'}
print(type(set1))

udayjkc
Автор

Printing dictionary values by key ... for the above example code you could print out using

>print(dict1[2])
which would print "Tuesday"

For a more complicated example, if the third key instead of 3 was "thirdKey" then you could print it using :
>print(f'dict1[thirdKey] = {dict1["thirdKey"]}')

SageArbor
Автор

Oh u made my understand it like a penny task

aryangaurvlogs
Автор

Hey may I ask? What IDE are you using?

jongab
Автор

Well explained... It remove my doubts regarding these topics

makhzansabeel
Автор

hi, thanks for the video.
whats' the IDE you're using on this video? it looks so cool and seems light, unlike the IDE I'm currently using. Takes time to load, and clumps most of my screen area.

stonedead
join shbcf.ru