Skip to main content

snake, water,gun game python

 import random

def check(comp, user):
    if comp==user:
        return 0
    if(comp==0 and user==1):
        return -1
    if(comp==1 and user==2):
        return -1
    if(comp==2 and user==0):
        return -1

    return 1
comp=(random.randint(0,2))
user=int(input("0 for snake, 1 for water and 2 for gun"))

score=check(comp, user)
print("your choice:", user)
print("computer choice:", comp)

if(score==0):
      print("its a draw")
elif(score==-1):
    print("you Lose")
else:
    print("you won")

Comments

Popular posts from this blog

associative mapping to behave as direct mapping

QUESTION: consider   a cache memory system with 4095 primary memory blocks and 128 cache memory blocks and block set associative mapping implemented the architecture 16 words are available per block, what should be the size of the set so that block set associative mapping technique behave like 1. associative mapping 2 .direct mapping ANS : In associative mapping technique primary memory block associated with any block of cache memory means 0 of primary memory block associated with 7 th block of cache memory. so for block set associated mapping technique to behave like associative mapping technique only 1 block set is required because any no of primary memory block can associated with any number of cache memory block so no extra set is needed in cache memory only 1 set is sufficient for block set mapping technique to behave like associative mapping. 2. In direct mapping   technique all blocks of cache memory are mapped by k-mod 128 technique. In k-mod 128 technique ...