Friday, December 5, 2014

Activity 1.3.6 Tuples and Lists



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? 
All tuples and lists are made up of strings, so they are longer and more complex. Also, tuples are immutable while lists are mutable.
2.  Why do computer programming languages almost always have a variety of variable types?    
Computer programming languages have a variety of variable types so that they can operate in an efficient manner appropriate to the scenario at hand. For example, Boolean is used for occasions where True and False are the only possible outputs.
3.  Why can't everything be represented with an integer?
Everything can't be represented with an integer because there aren't enough integers to represent everything such as letters. If all we used was integers, everybody would probably have a seizure.

No comments:

Post a Comment