-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpermutation jumbled words.py
More file actions
65 lines (59 loc) · 2.05 KB
/
permutation jumbled words.py
File metadata and controls
65 lines (59 loc) · 2.05 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
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 9 18:46:38 2021
@author: Priyanka Jhamb
"""
import random
def choose():
words=['Reverse','Word','priyanka','Jhamb','Daughter','Sister','Computer','Science','Engineering','Technology']
pick=random.choice(words)
return pick
def jumble(words):
jumbled="".join(random.sample(words, len(words)))
return jumbled
def thank(p1n,p2n,p1,p2):
print(p1n,"Your score is : ",p1)
print(p2n,"Your score is : ",p2)
print("Thankyou for participating in this game. Have a great day!")
def play():
p1name=input('Player 1 Name : ')
p2name=input("Player 2 Name : ")
p1p=0#player 1 points
p2p=0#player 2 points
turn=0
while 1:
#computer task
picked_word=choose()
#create the question
qn=jumble(picked_word)
print("Write your answer letters in small but first letter should be capital.")
print(qn)
if(turn%2!=0):
print(p1name, "Your turn!")
answer=input('What is on my mind?')
if answer==picked_word:
p1p=p1p+1
print('Your score is :', p1p)
turn=turn+1
else:
print("Your answer is wrong. I thought: ",picked_word, ". Better luck next time.")
c=input('Press 1 to continue and 0 to quit.')
c=int(c)
if c==0:
thank(p1name, p2name, p1p, p2p)
break
else:
print(p2name, "Your turn!")
answer=input('What is on my mind?')
if answer==picked_word:
p2p=p2p+1
print('Your score is :', p2p)
turn=turn+1
else:
print("Your answer is wrong. I thought: ",picked_word, ". Better luck next time.")
c=input('Press 1 to continue and 0 to quit.')
c=int(c)
if c==0:
thank(p1name, p2name, p1p, p2p)
break
play()