Posts

Showing posts from March, 2022

Dice.py

import random while True : throw_dice = input ( " Press yes/no to throw the Dice.. " ).lower() if throw_dice != "yes" : if throw_dice == "no" : print ( " Good Bye ! " ) break print ( " Please enter a valid input next time.. " ) continue else : dice = random.randrange( 0 , 7 ) print ( " Number is = " , dice)

NumberGuesser.py

import random num_range = input( " Enter a highest number of the range: " ) if not num_range.isdigit(): print( " Please enter a valid number.. " ) quit() else : num_range = int(num_range) ran_number = random.randrange( 0 , num_range + 1 ) incorrect_guess = 0 while True : guess = input( " Please guess a number: " ) guess = int(guess) incorrect_guess += 1 if guess == ran_number: print( " Correct guess! " ) print( " & you took" , incorrect_guess , "attempts to guess Correct number. " ) quit() elif guess < ran_number: print( " Incorrect guess & the number is higher than your guess. " ) else : print( " Incorrect guess & the number is lower than your guess. " )