public
Description: repository for the code featured in the blog
Homepage: http://python.genedrift.org
Clone URL: git://github.com/nuin/beginning-python-for-bioinformatics.git
100755 35 lines (25 sloc) 0.732 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
 
'''
an extremely simple dice game
'''
 
#we need the random module
import random
import string
 
#generating two dices, between 1 and 6 for the human player
dice1 = random.randint(1, 6)
dice2 = random.randint(1, 6)
 
#generating two dices, between 1 and 6 for the computer player
computerdice1 = random.randint(1, 6)
computerdice2 = random.randint(1, 6)
 
#summing up both dices for each player
mine = dice1 + dice2
his_hers = computerdice1 + computerdice2
 
#printing the values
print 'mine = ' + str(mine) + ' vs. computer = ' + str(his_hers)
 
#chdking the results and proclaiming the winner
if mine > his_hers:
    print "I won"
elif mine < his_hers:
    print "Computer won"
else:
    print "Tie. Try again"