-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The folder contains two files numbers-guess.py and rock-paper-scissors.py
- Loading branch information
1 parent
3f485da
commit 7e6d68f
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#number game | ||
import random | ||
|
||
print("This is the Higher Lower Guessing Game, where you have to guess a number and we will check how well you can guess") | ||
|
||
|
||
def play(): | ||
gen = random.randint(1, 100) | ||
#print(gen) | ||
|
||
gus = 0 | ||
tri = 0 | ||
|
||
while gus != gen: | ||
gus = int(input("Guess a nummber: ")) | ||
tri = tri + 1 | ||
if gus > gen: | ||
print("you need to guess lower, try again ") | ||
elif gus < gen: | ||
print("you need to guess higher, try again ") | ||
else: | ||
print("Congrats, you guessed it correct and You took " + str(tri) + " guesses to reach to the correct number") | ||
print("If you want to continue enter 1 and if you want to exit enter 0") | ||
x = int(input()) | ||
return (x) | ||
|
||
|
||
|
||
p =1 | ||
while(True): | ||
if p==0: | ||
break | ||
else: | ||
p = play() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#Rock Paper Scissors Game | ||
|
||
import random | ||
options =["rock", "paper", "scissors","rock", "paper", "scissors","rock", "paper", "scissors"] | ||
print("Welcome to Rock Paper Scissors Game") | ||
|
||
play = "yes" | ||
coscore=0 | ||
myscore=0 | ||
while play == "yes": | ||
comove= random.choice(options) | ||
mymove = input("What will you choose? rock, paper or scissors: ") | ||
print("Computer choose ", comove) | ||
if mymove==comove: | ||
print("it's a tie") | ||
elif mymove=="scissors" and comove=="rock": | ||
print("Computer wins") | ||
coscore = coscore + 1 | ||
elif mymove == "scissors" and comove == "paper": | ||
print("Player wins") | ||
myscore = myscore+1 | ||
elif mymove=="paper" and comove=="rock": | ||
print("Player wins") | ||
myscore = myscore+1 | ||
elif mymove=="paper" and comove=="scissors": | ||
print("Computer wins") | ||
coscore = coscore + 1 | ||
elif mymove=="rock" and comove=="paper": | ||
print("Computer wins") | ||
coscore = coscore+1 | ||
elif mymove=="rock" and comove=="scissors": | ||
print("Player wins") | ||
myscore = myscore+1 | ||
print("Your score is: ",myscore) | ||
print("Computer's score is: ",coscore) | ||
print("Do you want to play agin: yes/no") | ||
play = input() |