Thursday, December 4, 2014

Double dice roller/letter guesser

Connor Noble
AP Computer Science

This is the code I used for a dice roller that uses two dice.

It allows you to use different sized dice and not just 6 sided ones.  For this test I used normal 6 sided die.


















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 'b' can not be changed without changing the whole thing. 


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

They have a variety of variables to make sure there is always a  solution to the problem.   Everything cannot be represented by an integer because then some equations would not work the right way.

tweet verify code


Connor Noble
AP Computer Science


 This code goes throught the "tweet" and if one thing is not included then it will not go through the code, but instead will stop and tell you if you arte missing something.  

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 forty one characters in that sentence and it does not matter if because it is recognizing how many characters not bites.

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


First it stores 'one string' into a, 'another' into b, and a[:3] + 'and' + b. c would then equal "one and another". then c[6:10] is printed. That would be "d an".