Skip to content

Commit 9a4a78f

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 8652f4e + 92d13a2 commit 9a4a78f

File tree

4 files changed

+127
-0
lines changed

4 files changed

+127
-0
lines changed

.github/workflows/pylint.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Pylint
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.8", "3.9", "3.10"]
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python ${{ matrix.python-version }}
14+
uses: actions/setup-python@v3
15+
with:
16+
python-version: ${{ matrix.python-version }}
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install pylint
21+
- name: Analysing the code with pylint
22+
run: |
23+
pylint $(git ls-files '*.py')
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Python Package using Conda
2+
3+
on: [push]
4+
5+
jobs:
6+
build-linux:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
max-parallel: 5
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python 3.10
14+
uses: actions/setup-python@v3
15+
with:
16+
python-version: '3.10'
17+
- name: Add conda to system path
18+
run: |
19+
# $CONDA is an environment variable pointing to the root of the miniconda directory
20+
echo $CONDA/bin >> $GITHUB_PATH
21+
- name: Install dependencies
22+
run: |
23+
conda env update --file environment.yml --name base
24+
- name: Lint with flake8
25+
run: |
26+
conda install flake8
27+
# stop the build if there are Python syntax errors or undefined names
28+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
29+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
30+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
31+
- name: Test with pytest
32+
run: |
33+
conda install pytest
34+
pytest

.github/workflows/python-publish.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
10+
11+
on:
12+
release:
13+
types: [published]
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
deploy:
20+
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Set up Python
26+
uses: actions/setup-python@v3
27+
with:
28+
python-version: '3.x'
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install build
33+
- name: Build package
34+
run: python -m build
35+
- name: Publish package
36+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
37+
with:
38+
user: __token__
39+
password: ${{ secrets.PYPI_API_TOKEN }}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Number Guessing Game Explanation
2+
3+
This Python script implements a simple number guessing game where the user has to guess a randomly generated number within a certain number of rounds.
4+
5+
### How it Works
6+
7+
- The script starts by importing necessary modules: `random` for generating random numbers and `time` for implementing a countdown.
8+
- A random number between 0 and 99 is generated using `random.randint(0, 99)`.
9+
- The user is prompted to input the number of rounds they want to play.
10+
- If the input number of rounds is 0, the script prompts the user to enter a valid number of rounds.
11+
- Otherwise, a countdown of 3 seconds is initiated using `time.sleep(1)` and displayed on the console.
12+
- After the countdown, the game begins with the specified number of rounds.
13+
- In each round, the user is prompted to guess the number.
14+
- Feedback is provided to the user based on their guess:
15+
- If the guess is higher than the random number, the script informs the user that their input is greater.
16+
- If the guess is lower than the random number, the script informs the user that their input is less.
17+
- If the guess is equal to the random number, the script congratulates the user and ends the game.
18+
- The number of rounds remaining is decremented after each guess, and the user is informed about it.
19+
- The game continues until either the user guesses the correct number or runs out of rounds.
20+
21+
### How to Use
22+
23+
1. Clone the repository or download the Python script.
24+
```
25+
https://github.com/JawadSher/Python-Projects-Beginner-to-Advance/tree/main/Project%201%20-%20Number%20Guessing%20Game
26+
3. Run the script using Python 3.x.
27+
4. Enter the desired number of rounds when prompted.
28+
5. Follow the instructions to guess the random number within the specified rounds.
29+
30+
Enjoy playing the number guessing game!
31+

0 commit comments

Comments
 (0)