Header Ads

Header ADS

Simple Python Project for Beginner-02

Project-Rock Paper Scissor


Source Code:

import random
while True:
    player = input('rock(r),paper(p),scissor(s):')
    print(player+' (Player) vs (Computer) ',end = ' ')
    n = random.randint(1,3)
    if n == 1:
        com = 'r'
    elif n == 2:
        com ='p'
    else:
        com = 's'
    print(com)
   
    if com == player:
        print('Drawn!')
    elif com == 'r' and player == 's':
        print('com Wins')
    elif com == 'r' and player == 'p':
        print('Player Wins')
    elif com == 'p' and player == 's':
        print('Player Wins')
    elif com == 'p' and player == 'r':
        print('com Wins')
    elif com == 's' and player == 'p':
        print('com Wins')
    elif com == 's' and player == 'r':
        print('Player Wins')

Output:

কোন মন্তব্য নেই

Blogger দ্বারা পরিচালিত.