0% found this document useful (0 votes)
12 views

Assignment 1

The assignment involves creating a terminal-based Rock, Paper, Scissors game using a modular Python project structure. The project requires organizing code across multiple files, implementing game logic, and displaying scores, with specific instructions on file structure and import styles. The final submission should be a compressed .zip file of the project folder after testing the game.

Uploaded by

imemyself371
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Assignment 1

The assignment involves creating a terminal-based Rock, Paper, Scissors game using a modular Python project structure. The project requires organizing code across multiple files, implementing game logic, and displaying scores, with specific instructions on file structure and import styles. The final submission should be a compressed .zip file of the project folder after testing the game.

Uploaded by

imemyself371
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment 1

Rock, Paper, Scissors


In this assignment, you will create a terminal-based Rock, Paper, Scissors game using a
modular Python project structure. The primary goal is to practice how to organize code
across multiple files and folders, reuse functionality using imports, and apply elements of
Python’s standard library. Your game should repeatedly ask the user for input, determine the
winner of each round, display the running score, and continue until the user types "exit".

Project Structure:

Your project folder must be named rock_paper_scissors and organized using the following
structure:

rock_paper_scissors/

├── main.py

├── game/

│ ├── __init__.py

│ ├── logic.py

│ └── utils.py

└── tools/

└── display.py

The main.py file should serve as the entry point of your program, containing only the top-
level logic. All helper functions should be kept in their respective modules inside the game/
and tools/ folders.

The greeting message and the formatted print statements used for displaying messages and
scores should be placed inside a separate display.py file under the tools/ folder.

Implementation Tasks:

Start with main.py. Ask the user to enter their name. Then, display a welcome message using
a function from tools/display.py. This function should use an f-string to include the user's
name.
Import it with an alias, for example:

import tools.display as dsp

The game then enters a loop where the user is prompted to enter one of the following valid
moves: "rock", "paper", or "scissors". Use a helper function from game/utils.py to clean the
user input by stripping extra spaces and converting it to lowercase.

Game logic should be implemented in game/logic.py, inside a function called


decide_winner(user_move, computer_move).

The computer's move must be generated randomly using random.choice(['rock',


'paper', 'scissors']). The decide_winner() function should return one of the
following results: "You win!", "You lose!", or "It's a draw!".

After each round, main.py should print the computer’s move and the result of the round
using functions from tools/display.py. It should then update and print the current score in
the following format:

User: 2

Computer: 3

The game should continue until the user types "exit". You must demonstrate usage of at least
three different import styles across the project:

• import module

• from module import function

• import module as alias

Sample Gameplay:

Please enter your name: Alice

Welcome, Alice!
Let's play Rock, Paper, Scissors.
(Type 'exit' to quit.)

Your move: rock


Computer chose: paper
You lose!
Score:
User: 0
Computer: 1

Your move: paper


Computer chose: rock
You win!

Score:
User: 1
Computer: 1

Your move: exit


Thanks for playing!

Submission Instructions:

After testing your project by running only main.py, compress the entire rock_paper_scissors/
folder and submit it as a .zip file.

You might also like