wagtail / guide

A website to teach Wagtail CMS to content editors, moderators and administrators.
https://guide.wagtail.org
BSD 3-Clause "New" or "Revised" License
32 stars 26 forks source link

Python fundamentals #296

Closed activus-d closed 1 year ago

activus-d commented 1 year ago

Python coding challenge by Storm Program a game where the user has to guess a random number generated by the program. The program gives hints if the user’s input is lower or higher than the random number. The game ends when the user's input is the same as the random number. Conditions

activus-d commented 1 year ago

Solution

import random

def random_number_game():
    random_number = int(random.random() * 100)
    while True:
        print("Guess a number between 1-100")
        try:
            user_input = int(input())
        except ValueError:
            print("Please enter a number")
        if user_input == random_number:
                print("Yay, you win!")
                break
        elif user_input > random_number:
            print("Too high Please try again.")
        elif user_input < random_number:
                print("Too low. Please try again.")

random_number_game()
Peddinti-Sriram-Bharadwaj commented 1 year ago

hi, my name is Sriram Bharadawaj mail id - sriram9217@gmail.com

I would like to complete this code if you can assign me to it