AceInfinity
Emeritus, Contributor
So i'm taking an edX course for programming and computer science just for the fun of it based from MIT. Haha, it's kind of easy right now... First lecture, was to install python, and since I had nothing else to do but watch a bunch of boring videos, I came up with a HiLo game in python and learned how to import.
Python is too much of an easy language to understand, and I think that's why they chose it.
Python is too much of an easy language to understand, and I think that's why they chose it.
Code:
import random
# The number the user is trying to guess
x = int(random.uniform(1, 100))
# The user's guess for the current try
g = 0
# The number of tries taken to guess the number (counter)
numG = 0
while g != x:
# Take in user's guess and increment counter
g = int(raw_input('Take a guess (1-100): '))
numG += 1
# Check user's guess to tell them higher or lower
if g > x:
print('Your guess was too high! Guess lower.')
elif g < x:
print('Your guess was too low! Guess higher.')
# Game finished, user found the guess number
print('You finally guessed the number in ' + str(numG) + ' tries.')