import random def game_main(): game_strings = ["--Random Number Guessing Game--", "Guess a Number between {0} and {1}: ", "You {0}, the number was {1}"] MIN_GUESS = 1 MAX_GUESS = 10 GUESS_ANSWER = random.randint(MIN_GUESS,MAX_GUESS) YOUR_GUESS = float(input(game_strings[1].format(MIN_GUESS, MAX_GUESS))) winlose = "lose" print(game_strings[0]) if (GUESS_ANSWER/YOUR_GUESS) == 1: winlose = "win" print(game_strings[2].format(winlose, GUESS_ANSWER)) quest_string = "Do you want to play again?: " playornot = 0 while playornot == 0: game_main() repeat = input(quest_string) if repeat != "yes": playornot = 1
This is, if I understand it correctly "procedural programming". I've been trying to understand the concepts of OOP and I'm not sure I'm getting it. Could someone assist with understanding how I would utilize OOP in a setting such as this? I am a trial and error type of person when it comes to learning but, I do read and try to understand to the best of my ability.
Finally, any hints with making this code better in general? This code represents the best of my understanding on how to program thus far. Hints, tips, advice or keywords to look up on Google would be appreciated.