Friday, December 12, 2014

Activity 1.3.7


Conclusion

1.      Sometimes code using an iterative loop can be written without a loop, simply repeating the iterated code over and over as separate lines in the program. Explain the disadvantages of developing a program this way.
 It is very inefficient and tedious.


2.      Name a large collection across which you might iterate.
 The hardware store would iterate list for what they have in stock. 

3.      What is the relationship between iteration and the analysis of a large set of data?
 Iteration changes information about each item in data and data analysis only reads their statistics.

Monday, December 8, 2014

Activity 1.3.6- Tuples and Lists




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? 
 a is a string, b is multiple strings in a tuple, and c is multiple strings in a list.

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

Thursday, December 4, 2014

Activity 1.3.5-Strings







Objective:
  • Create a "Tweet Verfier Code" which checks:
    • No More then 140 Characters
    • That the following Characters were used ( ,  "  !  ?)
Conclusion Questions:


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 this sentence. Yes it matters, because it will take up four times more space.

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])

 a and b are saved in the code and c is defined as a[:3] + 'and' +b. When these variables are called, the code will take what is defined and use it for the variables.