-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrowd_computing.py
More file actions
54 lines (53 loc) · 1.64 KB
/
Crowd_computing.py
File metadata and controls
54 lines (53 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import random
def choose():
words=['rainbow','computer','science','programming','mathematics','player','condition','reverse','water','board']
pick=random.choice(words)
return pick
def jumble(word):
jumbled="".join(random.sample(word,len(word)))
return jumbled
def thank(p1n,p2n,p1,p2):
print(p1n,'Your score is : ',p1)
print(p2n,'Your score is : ',p2)
print("Thank's for playing ")
print("Have a nice day")
def play():
p1name=input("Player1, please enter your name ")
p2name=input("Player2,please enter your name")
pp1=0
pp2=0
turn=0
while(1):
#computers task
picked_word=choose()
#create question
qn=jumble(picked_word)
print(qn)
#player 1
if turn%2==0:
print(p1name,"your turn ")
ans=input("What is on my mind ? ")
if ans==picked_word:
pp1=pp1+1
print("Your new score is: ",pp1)
else:
print("Better luck next time.The answer is: ",picked_word)
c=input('Press 1 to continue and 0 to quit.')
if c==0:
thank(p1name,p2name,pp1,pp2)
break
#player 2
else:
print(p2name,"your turn ")
ans=input("What is on my mind ? ")
if ans==picked_word:
pp2=pp2+1
print("Your new score is: ",pp2)
else:
print("Better luck next time.The answer is: ",picked_word)
c=input('Press 1 to continue and 0 to quit.')
if c==0:
thank(p1name,p2name,pp1,pp2)
break
turn=turn+1
play()