What is the out put of this code? why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the out put of this code? why?

qamus={"food", "feed", "fed", "food"} print(len(qamus))

9th Jun 2020, 10:19 AM
Azad m. A.
Azad m. A. - avatar
4 Answers
+ 6
it is a set ,set removes duplicate elements,output is 3
9th Jun 2020, 10:25 AM
Abhay
Abhay - avatar
+ 3
3
9th Jun 2020, 10:31 AM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 2
3 because sets don't count duplicates but if it was dictionary [] then 4!
9th Jun 2020, 10:43 AM
Cameron Anderson
Cameron Anderson - avatar
+ 1
please, remember that dictionary ={} not accepts dupilation, not ordered as well, you can change its elements, the each key or value or both...For the key elements of dictionaries you can use immutable objects only.. List = [ ] you can change its elements,as well...accepts duplication as well...mutable Tuple = ( ) ordered , accepts duplication and immutable...Tuples are the programmers' perfect choice, as it is faster , the data is fixed , nothing accedently added or removed or its order could be changed.. Let 's work on Tuples, Thanks for your comments and kind supports.
9th Jun 2020, 12:37 PM
Azad m. A.
Azad m. A. - avatar