Stress is something everyone experiences in daily life, this project helps users understand their stress level.
It is based on a short survey from the Perceived Stress Scale (PSS-4) (Cohen et al., 1983) to identify their stress level: High, Medium, or Low.
It was built using Python, depending on the results, the program will guide the users to different relaxing activities.
This project contains three main files: project.py, click.py, and snake.py.
-
Validates user input (name,mood).
-
Presents PSS-4 questions one by one.
-
Calculates stress score using Dictionary lookup.
-
Directs users to diary, mini-games, or relaxing music.
low_open_file: Opens a text file where the user can write freely about stress-free feelings, or make a to-do list as motivation.mid_game_: Randomly selects and launches one of the two mini-games (click.pyorsnake.py).high_music: Opens a random relaxing music video from YouTube in the browser with import of webbrowser.
This is a mini-game created with Pygame.
- The goal is to click as many circles as possible within 30 seconds.
- The game generates circles in random positions, sizes, and colors.
- At the end, the program displays the user’s final score before returning to the main program.
This is another mini-game created with Pygame.
- The player controls a snake using the arrow keys (up, down, left, right).
- The snake grows longer each time it eats the target “fruit”.
- The game ends when the snake hits the screen border or collides with itself.
- There is no time limit, so users can play at their own pace as a way of relaxation.
Video Demo: https://youtu.be/uo7xhitIFmE
Terminal interface showing the stress test
-
platform able to run Python
-
install modules show in requirements.txt using:
pip install -r requirements.txt
-
run the program using:
python project.py
.
├── project.py
├── click.py
├── snake.py
└── assets/
├── code_with_stress_terminal.png
└── pygame_snake.png
- Pygame basics
- Game logic and event handling
- Regex
- Input validation
- Modular programming
- File handling
- Webbrowser module
There are several possible future improvements for this project:
- Graphical User Interface (GUI): Making the program GUI-based (instead of text-based) would make it more accessible and visually appealing.
- Data recording: Storing the record of the users' stress levels in SQL database, making it easier to filter, query, and analyse the results over time.
- More activities: Adding new games, music playlists, or guided breathing/meditation exercises could be included to provide more variety.
- Expanded survey: Increasing the number of questions could improve the accuracy and representativeness of the stress-level assessment.
CS50P Final Project
