question archive Discussion Topic: Lists or Dictionaries? In this module, you are working with lists and dictionaries
Subject:Computer SciencePrice:3.84 Bought6
Discussion Topic: Lists or Dictionaries?
In this module, you are working with lists and dictionaries. Consider the following scenario before you make your initial post.
1)Lists and dictionaries in Python are similar in that they are both used to store a collection of other data. In many cases, a programmer could use either one effectively to achieve a particular goal. Imagine a collection of some sort of data and propose which collection data type, a list or a dictionary, you would choose.
For your initial post, determine whether dictionaries or lists are the most efficient method, and provide a rationale based on what you learned in this module to support your decision.
Step-by-step explanation
Lists and dictionaries both are used popularly in python for processing data.
Lists are primarily the arrays of data where the data can be accessed using the index and the indexing can be arithmetically computed in loops. This is the biggest advantage with lists in python or any programming language. Arithmetic operation on array index allows faster operation on data sequentially. The ndarray (NumPy Array) is a multidimensional array used to store values of same datatype. These arrays are indexed just like Sequences, starts with zero. The operations using ndArray in python is far far faster rather than normal list and data frame array. In different algorithms of Machine Learning like K-means Clustering, Random Forest etc., ndArray are very usefull for fast processing of data. The speed is the most important factor in running and designing a machine learning programming/.coding.
Dictionary data types are again the arrays of data but the indexing is not the number but a label. The labels can be defined with some value and need not to be in a sequence. This enables a dictionary as an associative array. The index or label is the key of the dictionary that is associated (or mapped) to a value. The values of a dictionary can be any Python data type. So, dictionaries are unordered key-value-pairs.