Advertisement
DrAungWinHtut

dice4.py

May 8th, 2023
718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.40 KB | None | 0 0
  1. import os
  2. import random
  3.  
  4. coin = 0
  5.  
  6.  
  7. def Game():
  8.     global coin
  9.     bet = int(input('how much will you bet? : '))
  10.     if bet > coin:
  11.         print('\nNo... you cannot bet that much')
  12.         print(f'you only have {coin}')
  13.         print(f'your bet become {coin}')
  14.         bet = coin
  15.     input('\npress any key to roll..')
  16.     me = random.randint(1,6)
  17.     print(f'your number is {me}')
  18.    
  19.     print('\ncomputer turn')
  20.     comp = random.randint(1,6)
  21.     print(f'computer number is {comp}')
  22.     print()
  23.     if(comp>me):
  24.         print('computer wins')
  25.         coin = coin - bet
  26.     elif(comp<me):
  27.         print('you win')
  28.         coin = coin + bet
  29.     else:
  30.         print('draw')
  31.     print(f'\nyour coin is {coin}')
  32.     if coin == 0:
  33.         print('\nyou need to buy more coin')
  34.         print('will you buy or exit?')
  35.         ans = input('y/n? ')
  36.         if ans == 'y':
  37.             coin = int(input('\nhow many coin: '))
  38.         else:
  39.             print('\n\nSee you next time buddy!')
  40.             exit()
  41.    
  42.  
  43.  
  44.  
  45.  
  46.  
  47. # Program start here
  48. os.system('clear') # for windows use cls
  49. coin = int(input('how many coin? :'))
  50.  
  51. while(True):
  52.     print('1 - Play Game')
  53.     print('2 - Exit')
  54.     ans = input('1 or 2 ? : ')
  55.     if(ans=='1'):
  56.         print('\nPlaying Game...')
  57.         Game()
  58.         print()
  59.     if(ans=='2'):
  60.         print('Exiting now...')
  61.         print()
  62.         exit()
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement