Advertisement
Ad009

guessnummodified

May 5th, 2024
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.93 KB | None | 0 0
  1. import random #import random library
  2.  
  3.  
  4. dl= input('Enter Difficulty Level for guess the number game!:\n E for easy, M for medium, H for Hard, B for Blindfold Hard mode(No hints)') #Selects Difficulty level
  5.  
  6. if dl=='E' or dl== 'e':
  7.     maxn = 10
  8.     n = random.randint(1, maxn)
  9.     print('Welcome to guess the number game: Easy mode!')
  10.     print('Guess the number from 1 to %d' % maxn)
  11.     guess = None
  12.     while guess != n:
  13.         guess = int(input('Your try: '))
  14.         if guess > n:
  15.             print('Too high')
  16.         if guess < n:
  17.             print('Too low')
  18.         if guess==n:
  19.             print('Congratulations, You won!')
  20.  
  21.  
  22. elif dl=='M' or dl== 'm':
  23.     maxn = 50
  24.     n = random.randint(1, maxn)
  25.     print('Welcome to guess the number game: Medium mode!')
  26.     print('Guess the number from 1 to %d' % maxn)
  27.     guess = None
  28.     while guess != n:
  29.         guess = int(input('Your try: '))
  30.         if guess > n:
  31.             print('Too high')
  32.         if guess < n:
  33.             print('Too low')
  34.         if guess==n:
  35.             print('Congratulations, You won!')
  36.            
  37. elif dl == 'H' or dl== 'h':
  38.     maxn = 100
  39.     n = random.randint(1, maxn)
  40.     print('Welcome to guess the number game: Hard mode!')
  41.     print('Guess the number from 1 to %d' % maxn)
  42.     guess = None
  43.     while guess != n:
  44.         guess = int(input('Your try: '))
  45.         if guess > n:
  46.             print('Too high')
  47.         if guess < n:
  48.             print('Too low')
  49.         if guess==n:
  50.             print('Congratulations, You won!')
  51.  
  52. elif dl=='B':
  53.     maxn = 100
  54.     n = random.randint(1, maxn)
  55.     print('Welcome to guess the number game: Blindfold Hard mode!')
  56.     print('Guess the number from 1 to %d' % maxn)
  57.     guess = None
  58.     while guess != n:
  59.         guess = int(input('Your try: '))
  60.         if guess==n:
  61.             print('Congratulations, You won!')
  62. else:
  63.     print('Please enter a valid letter for difficulty level')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement