Our Project- Rock, Paper, Scissors

Introduction

In this project, we will program the rock paper scissors game on python. The main purpose of our project is to break down the code of this popular game and figure out it's components. Our driving question is "What is the code for the infamous Rock Paper Scissors game?". The hypothesis of this project is that if we use print functions and "if, else" loops, we can code the Rock Paper Scissors game on python. 

Materials 

Safety:

There is no particular safety precautions that you need to make besides avoiding sketchy/pirated sites and choosing reliable sites.

Pictures & Procedure 

Define user choice 

Since this is a 2 player game, the computer will input a ranom choice and the player will input a choice of their own (rock, paper, or scissors). Any other input will recieve an error code. We define the user_choice function and return the results.

Define computer choice & winner determination

After defining user choice, we define the computer's choice with the return random.choice command. Then we form our function to determine the winner. If the user and computer choice are =, the screen will display tie. The elif/ else functions serve to display the outcomes of the scenarios for the 3 possible inputs from both sides. Based on that, the function returns "You win" or "computer wins".

Print game messages & results

After we define our functions, we print. First we print a welcome message. Then we get the user's choice, followed by the computer's choice. Then, we display the choices from both by printing. Lastly, we determine the results by calling the determine_winner function and printing the results. 

Results 

Above are the results after running the code three time and inputting rock, paper, and scissors for the 3 rounds respectivally. 

Scientific Principles/ Essential Understanding

Real Life Application:

Rock, Paper, Scissors is a fair game played between two people. It is commonly used to settle a dispute and come to an agreement. This game is similar to the classic coin flip, except that it has three outcomes instead of two. 


Observations

We observed that the computer can generate it's own choice by importing random. We also saw that we could call many functions to play a fun game. 


Analysis and Discussion: 

This program is a demonstration of a few basic function types in python. We used our knowledge of defining functions, importing, printing, and more. We saw how the computer generates random choices and the results the program returns upon interpreting the user and computer choice. 

Conclusion: 

In conclusion, we put our knowledge of different functions of python into this code and realized how a fun and interactive game can be created. With a few revisions and some research, we were able to program a simple game with the least amount of lines of code used. 

Investigation Questions: 

What is the purpose of an elif function. 

Elif stands for "else if". In python, it is used to test multiple conditions. In our case, we needed to evaluate the different possibilities of inputs from both the computer and the user. We had to determine who would win in different scenarios. For instance, in the case of the elif function, we listed out the scenarios where the user would win. Then we used "else" to indicate that the computer would win in any other scenario not listed in the if or elif. 

How does the computer know what to pick?

When we say import random, that is for the computer. We define the computer choice get_computer_choice and we return the 3 random choices. From there, the program randomly assigns a choice for the computer. 

Which function calls the results?

The result is the called determine_winner function. It is expressed when printed as the last line of code shows. 

What if I don't input rock paper or scissors?

If you do not input a choice that is recognized by the program, a message will print expressing the invalidity of the input as line 8 of the code suggests.