Net-informations.com
SiteMap  | About    

Python Interview Questions FAQ - 2

Please click on the questions to see the answers

You would only use the Dictionary if you needed to map (or associate) meaningful keys to values, whereas a List only maps (or associates) positions (or indices) to values.

output

output

List comprehensions provide a concise way to create lists. Common applications are to make new lists where each element is the result of some operations applied to each member of another sequence or iterable, or to create a subsequence of those elements that satisfy a certain condition.

output

same as :

output

Python 3.3+ adds list.copy() method, which should be as fast as slicing:

output

The range() is the built-in function to be used for iterating the sequence of numbers.

Python supports six sequence types, they are:

  1. strings
  2. unicode strings
  3. lists
  4. tuples
  5. buffers
  6. range objects

You can use shell redirection while executing the python file.

The reversed() method returns an iterator that accesses the given sequence in the reverse order.









net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.