Thursday, January 22, 2015

1.3.6: Lists and Tuples

1.3.6: Lists and Tuples

1: Below are examples of a string, tuple, and list of characters, respectively: 

a = 'acbde'
                 b = ('a', 'b', 'c', 'd', 'e')
                 c = ['a', 'b', 'c', 'd', 'e']
  a[2] is a part of a string and thus cannot be indexed like a list or tuple, while b[2] is in a tuple, so it is not able to be changed. c[2] is in a list, so it may function like a tuple, but it can also be changed.



2: The reason for having multiple variable types is to be able to have the most efficient way of storing data within a program, so you can find the most efficient way to solve the problem you have. Having multiple variable types allows you to solve problems more quickly, and having more options in your code is better to become a better programmer

No comments:

Post a Comment