Friday, December 12, 2014

loops

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.

its way is slow and has lager windo for humin errer.

Name a large collection across which you might iterate.

to find incrrect words in a word doc.

1.       What is the relationship between iteration and the analysis of a large set of data?

they both look for certan information in a large set of data just use diffent ways of finding them.

Monday, December 8, 2014

tunip work

#15
import random a = random.randint(1,6)
b = random.randint(1,6)
c = a + b

16
import random
a = ['a','b','c','d','e','f','g','h','i','j','k','l','n','m','o','p','q','r','s','t','u','v','w','x','y','z']

c = random.choice(a)

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? 

c is a list and b is a string.

1.       Why do computer programming languages almost always have a variety of variable types? Why can't everything be represented with an integer?

it makes it easyer to represent when dealing with mass amouts of integers.

strings

my code for the tweet checker:

def tweet_good(post):
Error = 0
if len(post) > 140:
print "Too long"
if len(post) <140:
print "all good size"

else:
Error = Error + 1
if '!' in post:
Error = Error + 1
if ',' in post:
Error = Error + 1
if '?' in post:
Error = Error + 1
if '"' in post:
Error = Error + 1

else:

if Error >= 5:
print "all good"
if Error < 5:
print "missing things"









tweet check



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?

There are 41 characters  in that sentence. it dosent matter because there all the same just characters to python it wouldnt matter.

1.       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.

with only line 3 you would get (one and another), but with line 4 it only would say (d a).