Python package that allows the user to play four different academic games which aim to improve the player's abilities in four different subjects. Developed with pipenv, built with build using setuptools, uploaded to PyPI using twine, and distributed via pip.
Project description
Python Package Exercise
Team members
Description
This is an educational quiz game package. Choose between playing a math game, vocab game, geography game, or science game to test your skills and knowledge!
PyPI Link
Steps necessary to run program
Package installation steps
- Create
pipenvvirtual environment:
pip install pipenv
- Activate virtual environment:
pipenv shell
- Install package:
pipenv install quizlearnpackage
- Import package into Python
from quizlearnpackage import quizlearn
- Choose quiz type and enjoy!
# sample usage
quizlearn.play_vocab('hard', 'both', 12)
Running example usages
- First, clone the respository:
git clone https://github.com/software-students-spring2025/3-python-package-usps-525-3-violation.git
- Then change directories into the repository:
cd 3-python-package-usps-525-3-violation
- Create
pipenvvirtual environment:
pip install pipenv
- Activate virtual environment:
pipenv shell
- Run example script:
PYTHONPATH=src python3 -m quizlearnpackage
- Follow instructions and enjoy!
How to contribute to quizlearnpackage
- First, clone the respository:
git clone https://github.com/software-students-spring2025/3-python-package-usps-525-3-violation.git
- Then change directories into the repository:
cd 3-python-package-usps-525-3-violation
- Create
pipenvvirtual environment:
pip install pipenv
- Activate virtual environment:
pipenv shell
- After making contributions, verify that they pass tests:
PYTHONPATH=src pipenv run pytest --cov=quizlearnpackage --cov-report=term-missing
- Upload to PyPI
Remove any
distorsrc/*.egg-info, and increment version inpyproject.toml. Then,
pip install build twine
python -m build
twine upload dist/*
Function usages and examples:
play_math(level, num_questions)
This function starts a math quiz game. Users can choose the number of questions, and the difficulty of the questions to be easy, medium, or hard. Users interact with the function via input().
| Argument | Type | Description |
|---|---|---|
level |
string |
Must be either 'easy', 'medium', or 'hard'. Indicates difficulty level of arithmetic problems. |
num_questions |
int |
Indicates how many questions will be asked |
>>> play_math('easy', 3)
8 * 5 =
Input your answer: 40
Correct!
30 / 3 =
Input your answer: 10
Correct!
4 * 1 =
Input your answer: 4
Correct!
Well done! 3/3 Correct
Elapsed time: 5.4 seconds
play_geo(numOfQuestions, difficulty)
This function will prompt users to begin a geography quiz game that will challenge their knowledge on a diverse set of world geography questions. At each difficulty level of easy, medium, and hard, there will be 15 questions to be answered. The questions will range from topics about countries, states, rivers, to capitals. Once the user is finished with answering a question, they will be informed on whether the answer they provided was correct or not. At the end, they will be given a final score of how many questions they were able to answer correctly
| Argument | Type | Description |
|---|---|---|
difficulty |
string |
Revolves around three levels of difficulty from 'easy', 'medium', to 'hard'. |
numOfQuestions |
int |
Number of questions prompted for users to answer at each difficulty level. |
Exceptions Raised:
ValueError("Invalid number of questions"):numOfQuestionsless than 1 or greater than 15 questionsValueError("Invalid difficulty"):leveloutside of['easy', 'medium', 'hard']TypeError("Invalid type for numOfQuestions"):numOfQuestionsis not an integer value (e.g. in cases where the user is passing a float value or string when only an integer is suitable)
>>> play_geo(numOfQuestions=8, difficulty='easy')
What is the capital of Germany?
Your answer: Berlin
Correct!
Which continent is home to the Sahara Desert?
Your answer: Africa
Correct!
Which country has the largest population in the world?
Your answer: China
Correct!
Which U.S. state is known for having the Grand Canyon?
Your answer: Nevada
Incorrect! The correct answer was Arizona.
What is the name of the mountain range that separates Europe and Asia?
Your answer: Ural Mountains
Correct!
Which ocean borders the eastern coast of the United States?
Your answer: Pacific
Incorrect! The correct answer was Atlantic.
What is the capital of Argentina?
Your answer: Buenos Aires
Correct!
Which country is known for the ancient ruins of Machu Picchu?
Your answer: Bolivia
Incorrect! The correct answer was Peru.
Your final score: 6/8 (75%)
play_vocab(level, mode, num_questions)
This function starts a vocab quiz game. Users can choose between three difficulties -- easy, medium, and hard -- and between three gamemodes -- synonyms only, antonyms only, or both. Users can also choose a number of questions to be asked between 1 through 15. There are 20 synonym/antonym tuples for each difficulty, and for each question, users can choose between 4 multiple choice answers. At the end, the score is printed. Users interact with the function via input(). Questions are capped at 15 to prevent the same words from appearing too many times in one game session.
Exceptions raised:
ValueError("Invalid difficulty"):leveloutside of['easy', 'medium', 'hard']ValueError("Invalid gamemode"):modeoutside of['synonyms', 'antonyms', 'both']ValueError("Invalid number of questions):num_questionsless than 1 or greater than 15
| Argument | Type | Description |
|---|---|---|
level |
string |
Must be either 'easy', 'medium', or 'hard'. Indictes which difficulty level of the wordbank questions will be drawn from. |
mode |
string |
Must be either 'synonyms', 'antonyms', or 'both'. Indicates which types of questions will be asked. |
num_questions |
int |
Must be between 1 and 15. Indicates how many questions will be asked. |
>>> play_vocab('hard', 'both', 3)
Which word is an antonym for Exultant?
A: Melancholic
B: Perspicacious
C: Indolent
D: Intrepid
Choose A, B, C, or D:
>>> a
Correct!
Which word is an antonym for Diligent?
A: Pusillanimous
B: Frugal
C: Indolent
D: Thrifty
Choose A, B, C, or D:
>>> d
Incorrect. The correct answer was Indolent
Which word is a synonym for Ephemeral?
A: Dauntless
B: Imperious
C: Transient
D: Ostentatious
Choose A, B, C, or D:
>>> c
Correct!
Your total score this game was 2/3: 66%
play_science(num_questions, difficulty)
This function starts a science quiz game. Users can choose number of questions, ranging from 1 to 10, and choose the difficulty of the questions to be easy, hard, or a mix of both. Users interact with the function via input().
| Argument | Type | Description |
|---|---|---|
num_questions |
int |
Number of questions you will be given, has to be between 1 and 10. |
difficulty |
string |
Difficulty of the questions, must be easy, hard, or mix for a mix of questions of both difficulties. |
>>> package.play_science(num_questions=10, difficulty='easy')
What do you call the study of weather, climate and the atmosphere?
A: Climatology
B: Aerology
C: Atmospheric Science
D: Meteorology
Please enter A, B, C, or D: a
Incorrect! The correct answer was Meteorology.
Press ENTER to continue
Who is credited with coming up with the theory of evolution?
A: Robert Oppenheimer
B: Galileo Galilei
C: Charles Darwin
D: Gregor Mendel
Please enter A, B, C, or D: a
Incorrect! The correct answer was Charles Darwin.
Press ENTER to continue
What are the three layers of the Earth
A: Outer shell, inner shell, and center
B: Land, water, and atmosphere
C: Rock layer, magma layer, and deep core
D: Crust, mantle and core
Please enter A, B, C, or D: d
Correct!
Press ENTER to continue
You need to study more! Your score was 1/3.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quizlearnpackage-0.1.6.tar.gz.
File metadata
- Download URL: quizlearnpackage-0.1.6.tar.gz
- Upload date:
- Size: 55.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fb4e571782840e21eb9141f0afde5b9e2e95182d4278d7e97747ee310ad6a66
|
|
| MD5 |
26efbc0cfc1aa99e72e1052a1ece21dd
|
|
| BLAKE2b-256 |
5456e4f80fc95ae32a8c0513ce342ce879eeefc477e69d9539262e8fb2352fde
|
File details
Details for the file quizlearnpackage-0.1.6-py3-none-any.whl.
File metadata
- Download URL: quizlearnpackage-0.1.6-py3-none-any.whl
- Upload date:
- Size: 36.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26185a37505a5f9e6ae3ea08e3e0692e740c09fd3cda91d989d84742feea9551
|
|
| MD5 |
b7d54ef9d955758374128ada58c0a561
|
|
| BLAKE2b-256 |
1a38a6b6281f78332a3dcc27f6d2b045a01c99d88fcfc61725c96d29d787e6f4
|