Thursday, December 4, 2014

1.3.6 Conclusion Questions
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? 
2.  Why do computer programming languages almost always have a variety of variable types?    
3.  Why can't everything be represented with an integer?
1. a, b, and c are different because 'a' is a string, 'b' is a tuple, and 'c' is a list. They would function in different ways when used with certain code because of this.
2. Computer programming languages almost always have a variety of variable types because the computer needs to know whether it should treat something like 5 as a number or a letter. If it treats it like a letter 5 + 4 would be 54  and if it treats it like a number 5 + 4 would be 9.
3.Everything can't be represented with an integer because sometimes you need letters which aren't integers. If you wanted to store a sentence you wouldn't be able to.

1.3.6 Code
File
Picture

No comments:

Post a Comment