Thursday, December 4, 2014

1.3.6 Tuples and Lists

My Code For 15 and 16:

1.       Consider a string, tuple, and list of characters.

In []: a = 'acbde'
In []: b = ('a', 'b', 'c', 'd', 'e')
In []: c = ['a', 'b', 'c', 'd', 'e']

The values of a[3], b[3], and c[3] are all the same. In what ways are a, b, and c different?

                'a' uses a single string to hold of the letters. 'b' uses a tuple to contain all of the                  letters. 'c' uses a list to contain all of the values


2.      Why do computer programming languages almost always have a variety of variable types? Why can't everything be represented with an integer?

                Representing everything with integers would make very large numbers. For                      example, representing the alphabet using binary, would leave 26 integers in a row to get        'Z'.

No comments:

Post a Comment