Wednesday, December 10, 2014

Conclusion


Conclusion
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?
They are different because one of them was taken out of a complete string, one was taken from a list, and one was taken from a set of strings.
List: Elements of list can be changed
Tuple: Elements of tuple cannot be changed
String: Is a whole


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 a variety of types so that if you need to put different values together you can make it easier. Everything can not be an integer because some things can not be represented by a number

Thursday, December 4, 2014

Tweet












1.       How many characters are in this sentence? Does it matter whether Python is storing the string as one byte per character or four bytes per character?
41 characters are in the sentence. It should not matter as long as it is consistently stored.



2.      This question asks you about something you have not learned. In fact, the question is asking about details that go beyond what you will learn in this course. However, wondering what is going on at a lower level of abstraction – and talking about it – can be a useful strategy when learning about computing.

Describe what you think occurs in memory when the following code is executed.

In []: a = 'one string'
In []: b = 'another'
In []: c = a[:3] + ' and ' + b
In []: print(c[6:10])

It sets 2 variables and the 3rd line takes certain characters out of the strings and sets it to 'C', which equals ona and another. It then says to print the 6th through the 10th character making it print: 'd an'.