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.

No comments:

Post a Comment