|
| 1 | +#guess movie |
| 2 | +import random |
| 3 | +movies=["anand","drishyam","nayakan","gol maal","vikram vedha","black friday","dangal","godfather","dark night"] |
| 4 | + |
| 5 | +def create_question(movie): |
| 6 | + n=len(movie) |
| 7 | + letters=list(movie) |
| 8 | + temp=[] |
| 9 | + for i in range(n): |
| 10 | + if letters[i]== " ": |
| 11 | + temp.append(" ") |
| 12 | + else: |
| 13 | + temp.append("*") |
| 14 | + qn =" ".join(str(x) for x in temp) |
| 15 | + return qn |
| 16 | + |
| 17 | +def is_present(letter,movie): |
| 18 | + c=movie.count(letter) |
| 19 | + if c==0: |
| 20 | + return False |
| 21 | + else: |
| 22 | + return True |
| 23 | + |
| 24 | +def unlock(qn,picked_movie,letter): |
| 25 | + ref=list(picked_movie) |
| 26 | + qn_list=list(qn) |
| 27 | + temp=[] |
| 28 | + n=len(picked_movie) |
| 29 | + for i in range(n): |
| 30 | + if ref[i]==" " or ref[i]==letter: |
| 31 | + temp.append(ref[i]) |
| 32 | + else: |
| 33 | + if qn_list[i]=="*": |
| 34 | + temp.append("*") |
| 35 | + else: |
| 36 | + temp.append(ref[i]) |
| 37 | + |
| 38 | + qn_new =" ".join(str(x) for x in temp) |
| 39 | + return qn_new |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +def play(): |
| 47 | + p1name=input("Player 1!please enter your Name:") |
| 48 | + p2name=input("Player 2!please enter your Name:") |
| 49 | + pp1=0 |
| 50 | + pp2=0 |
| 51 | + turn=0 |
| 52 | + willing=True |
| 53 | + while willing: |
| 54 | + if turn%2==0: |
| 55 | + print(p1name,",your turn") |
| 56 | + picked_movie=random.choice(movies) |
| 57 | + qn=create_question(picked_movie) |
| 58 | + print(qn) |
| 59 | + modified_qn=qn |
| 60 | + not_said=True |
| 61 | + while not_said: |
| 62 | + letter=input("Your letter:") |
| 63 | + if(is_present(letter,picked_movie)): |
| 64 | + modified_qn = unlock(modified_qn,picked_movie,letter) |
| 65 | + print(modified_qn) |
| 66 | + d=int(input("Press 1 to guess the movie or 2 to unlock another character")) |
| 67 | + if d==1: |
| 68 | + ans=input(" your Answer:") |
| 69 | + if ans==picked_movie: |
| 70 | + print("Yay! Correct answer.") |
| 71 | + pp1=pp1+1 |
| 72 | + print(p1name,"your Score=",pp1) |
| 73 | + not_said=False |
| 74 | + else: |
| 75 | + print("Wrong Answer, Try again...") |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + else: |
| 80 | + print(letter,'not found') |
| 81 | + c=int(input("press 1 to continue or 0 to exit:")) |
| 82 | + if c==0: |
| 83 | + print(p1name,",Your Score is",pp1) |
| 84 | + print(p2name,",Your Score is",pp2) |
| 85 | + print("Thank you for playing, have a nice day!!!") |
| 86 | + willing=False |
| 87 | + |
| 88 | + else: |
| 89 | + print(p2name,",your turn") |
| 90 | + picked_movie=random.choice(movies) |
| 91 | + Q=create_question(picked_movie) |
| 92 | + print(qn) |
| 93 | + modified_qn=qn |
| 94 | + not_said=True |
| 95 | + while not_said: |
| 96 | + letter=input("Your letter:") |
| 97 | + if(is_present(letter,picked_movie)): |
| 98 | + modified_qn = unlock(modified_qn,picked_movie,letter) |
| 99 | + print(modified_qn) |
| 100 | + d=int(input("Press 1 to guess the movie or 2 to unlock another character:")) |
| 101 | + if d==1: |
| 102 | + ans=input("Answer:") |
| 103 | + if ans==picked_movie: |
| 104 | + print("Yay! Correct answer.") |
| 105 | + pp2=pp2+1 |
| 106 | + print(p2name,"your Score=",pp2) |
| 107 | + not_said=False |
| 108 | + else: |
| 109 | + print("Wrong Answer, Try again...") |
| 110 | + else: |
| 111 | + print(letter,'not found') |
| 112 | + c=int(input("press 1 to continue or 0 to exit:")) |
| 113 | + if c==0: |
| 114 | + print(p1name,",Your Score is",pp1) |
| 115 | + print(p2name,",Your Score is",pp2) |
| 116 | + print("Thank you for playing, have a nice day!!!") |
| 117 | + willing=False |
| 118 | + |
| 119 | + turn=turn+1 |
| 120 | +play() |
0 commit comments