def guess_letter():
alphabet = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z')
print random.choice(alphabet)
def roll_dice():
a = random.randiant(1,6)
b = random.randiant(1,6)
print a + b
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' uses a string to keep the letters. 'b' is a tuple that holds them. 'c' is a list to keep its values
2.
Why
do computer programming languages almost always have a variety of variable
types? Why can't everything be represented with an integer?
There is a variety because not all variables can be used in the same situation they might have only a certain one that can be used.
No comments:
Post a Comment