this is the problem I am working on. I have been programming for a total of 9 days so I am very new. I am attempting to write a function that generates a random integer between -1,200 and 1,200, and returns a statement dependent of the number. The statements are: number generated: is greater than 800, return ‘Heidi wins’/ less than or equal to 800 and is an EVEN number, return ‘Magic wins’. / less than or equal to 800 and ends with a 3, return ‘Tally wins’. / less than or equal to 800 and ends with a 5, print ‘Chelsea wins’. Otherwise, print ‘Big Girl wins’. Here is my program so far: please help with finishing it up. thank you.
def sillyGame(n):
mychoices=[
number=random.choice(myChoices)
inputNum=raw_input("Enter a number:")
numbers=['0','1','2','3','4','5','6','7','8','9','.']
isValidNumber=True
for ch in inputNum:
for element in numbers:
isMatch=False
if ch ==element:
isMatch=True
break
if isMatch==False:
isValidNumber==False
break
if isValidNumber==True:
print("this is a valid number")
else:
print("this is not a valid number")
If your question is as you stated in your comments, then…
To detect if x is less than 800:
if x < 800To detect if x is even:
if x % 2 == 0To detect if x ends in a 3:
str(x)[-1] == "3"And any combination uses the keywords
ororand:if x < 800 and x % 2 == 0:Hope that helps.