Dice Roller/Letter Picker Code:
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?
a[3] is in a string, and cannot be indexed like a list or tuple. b[3] is in a tuple, which means it's immutable - unable to be altered in any way. c[3] is in a list, which means it works like a tuple (an array of indexed values), but it can also be changed (mutable).
2.
Why
do computer programming languages almost always have a variety of variable
types? Why can't everything be represented with an integer?
There are many variable types because we need a way to manipulate integers and values in a way that allows us to create functions and solve problems. While the computer eventually transforms the code into integers - 1's and 0's - it is manipulated at the programming level by substituting integers with letters and other symbols, which allows us to do more complex things with it.
this is ok but ive seen better
ReplyDelete