Skip to content

Commit 15efb57

Browse files
committed
Create project Number Guessing Upper Boundary,Added special character for Password Generator,Correct Spelling for Number Guessing
1 parent 0eedf05 commit 15efb57

6 files changed

Lines changed: 77 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.ipynb_checkpoints
22
*/.ipynb_checkpoints/*
3+
.idea
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import random
2+
import time
3+
4+
guess = None
5+
upper_boundary = None
6+
lower_boundary = 1
7+
8+
try:
9+
print('Hello! Welcome to the Number Guessing game')
10+
time.sleep(1)
11+
upper_boundary = int(input('Enter an upper boundary: '))
12+
answer = random.randint(1, upper_boundary)
13+
time.sleep(1)
14+
guess = int(input('Guess the answer by enter a number between {0} and {1}: '.format(lower_boundary,upper_boundary)))
15+
16+
while guess != answer:
17+
if guess < 1 or guess > upper_boundary:
18+
time.sleep(1)
19+
guess = int(input('Invalid input! Please enter a number between {0} and {1}: '.format(lower_boundary,upper_boundary)))
20+
elif guess < answer:
21+
print('Your guess is lower than the answer. Try again!')
22+
lower_boundary = guess
23+
time.sleep(1)
24+
guess = int(input('Enter a number between {0} and {1}: '.format(lower_boundary,upper_boundary)))
25+
elif guess > answer:
26+
print('Your guess is higher than the answer. Try again!')
27+
upper_boundary = guess
28+
time.sleep(1)
29+
guess = int(input('Enter a number between {0} and {1}: '.format(lower_boundary,upper_boundary)))
30+
31+
print('Congrats, Your guess is correct!')
32+
33+
except Exception as e:
34+
if upper_boundary is None:
35+
upper_boundary = int(input('Please enter a number for upper boundary: '))
36+
else:
37+
guess = int(input('Invalid input! Please enter a number between {0} and {1}: '.format(lower_boundary,upper_boundary)))
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!--Please do not remove this part-->
2+
![Star Badge](https://img.shields.io/static/v1?label=%F0%9F%8C%9F&message=If%20Useful&style=style=flat&color=BC4E99)
3+
![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)
4+
5+
# Number Guessing with Upper Boundary
6+
<!--An image is an illustration for your project, the tip here is using your sense of humour as much as you can :D
7+
8+
You can copy paste my markdown photo insert as following:
9+
<p align="center">
10+
<img src="your-source-is-here" width=40% height=40%>
11+
-->
12+
![number_guessing](https://user-images.githubusercontent.com/65219841/183583208-d9ebbbc9-0319-44bf-a889-8f6f10df55bb.png)
13+
14+
15+
## 🛠️ Description
16+
<!--Remove the below lines and add yours -->
17+
This is a number guessing game where you can decide the upper boundary. You have unlimited chances until you guess the correct answer.
18+
19+
## ⚙️ Languages or Frameworks Used
20+
<!--Remove the below lines and add yours -->
21+
The only python module that is required is random.
22+
You can install it using ```pip install random```
23+
24+
## 🌟 How to run
25+
<!--Remove the below lines and add yours -->
26+
Running the script is really simple! Just open a terminal in the folder where your script is located and run the following command:
27+
```python NumberGuessing.py```
28+
29+
## 📺 Demo
30+
![Screenshot 2022-08-09 144140](https://user-images.githubusercontent.com/65219841/183583519-f33a63a8-1789-4bbc-9153-08220da47d00.jpg)
31+
32+
33+
## 🤖 Author
34+
<!--Remove the below lines and add yours -->
35+
<a href= "https://github.com/kacoccc">Kacoccc

Number Guessing/number_guessing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
print('Hello World! Welcome to the game')
44
time.sleep(2)
55
n = random.randint(1, 10)
6-
print('Number has been generated!!\nYou have 4 chnaces to guess the number')
6+
print('Number has been generated!!\nYou have 4 chances to guess the number')
77

88
count = 4
99

Password Generator/password_generator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def process():
1414
lower = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
1515
upper = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
1616
num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
17-
all = lower + upper + num
17+
special = ['@', '#', '$', '%', '&', '*']
18+
all = lower + upper + num + special
1819
ran = random.sample(all,length)
1920
password = "".join(ran)
2021
messagebox.showinfo('Result', 'Your password {} \n\nPassword copied to clipboard'.format(password))

0 commit comments

Comments
 (0)