Advertisement
DrAungWinHtut

dice3.py

May 7th, 2023
962
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. import os
  2. import random
  3. def Greeting(name):
  4.     print('Hello, ' + name )
  5.     print('How are you today')
  6.  
  7. def Game():
  8.     input('press any key to roll..')
  9.     me = random.randint(1,6)
  10.     print(f'your number is {me}')
  11.     print()
  12.     print('computer turn')
  13.     comp = random.randint(1,6)
  14.     print(f'computer number is {comp}')
  15.     if(comp>me):
  16.         print('computer wins')
  17.     elif(comp<me):
  18.         print('you win')
  19.     else:
  20.         print('draw')
  21.  
  22.  
  23.  
  24.  
  25. # Program start here
  26. os.system('clear') # for windows use cls
  27. while(True):
  28.     print('1 - Play Game')
  29.     print('2 - Exit')
  30.     ans = input('1 or 2 ? : ')
  31.     if(ans=='1'):
  32.         print('Playing Game...')
  33.         Game()
  34.         print()
  35.     if(ans=='2'):
  36.         print('Exiting now...')
  37.         print()
  38.         exit()
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement