Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added day61 #381

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions day61/Python/Number_Guessing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import random

# set our game ending flag to False
game_running = True

while game_running:
# Greet the user to our game
print()
print("I'm thinking of a number between 1 and 100, can you guess it?")

# have the program pick a random number between 1 and 10
secret_number = random.randint(1, 100)

# set the player's guess number to something outside the range
guess_number = -1

# loop until the player guesses our number
while guess_number != secret_number:

# get the player's guess from the player
print()
guess = input("Please enter a number: ")

# does the user want to quit playing?
if guess == "quit":
game_running = False
break

# otherwise, nope, player wants to keep going
else:
# convert the players guess from a string to an integer
guess_number = int(guess)


# did the player guess the program's number?
if guess_number == secret_number:
print()
print("Congratulations, you guessed my number!")

# otherwise, whoops, nope, go around again
if guess_number < secret_number:
print()
print("Your guess is too low.")

if guess_number > secret_number:
print()
print("Your guess is too high.")


# say goodbye to the player
print()
print("Thanks for playing!!")
11 changes: 11 additions & 0 deletions day61/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
![cover](./cover.png)

# Day 61 - Loops: While

## Solution

## Python Implementation

```js
// To Be Added
```