-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOdds on.py
More file actions
35 lines (28 loc) · 938 Bytes
/
Odds on.py
File metadata and controls
35 lines (28 loc) · 938 Bytes
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
#Odds On Game
import random
def getInteger(message):
while(True):
inputText = input(message)
try:
inputInt = int(inputText)
if inputInt < 1:
raise ValueError
return inputInt
except ValueError:
print("PLEASE ENTER A POSITIVE INTEGER")
def getOddsChoice(message, odds):
while(True):
inputInt = getInteger(message)
if inputInt <= odds:
return inputInt
else:
print("MUST BE NO GREATER THAN MAX OF ODDS RANGE")
odds = getInteger("Enter max value of your odds range: ")
computerChoice = random.randint(0,odds)
userChoice = getOddsChoice("Enter your choice of odds: ", odds)
if computerChoice==userChoice:
print("MATCH")
else:
print("MISMATCH")
print("Computer's choice = " + str(computerChoice))
print("Your choice = " + str(userChoice))