In this mini-project, we will build a rock, paper, scissors game in the following steps:
Define a list ["rock", "paper", "scissors"]
, use
choice()
function from random
module to
randomly select an element from the list, name it
computer_choice
.
Now ask for user input. The input value should be in the list.
Name the input your_choice
.
Using if
, elif
, and else
to determine who wins.
Jupyter Notebook
Jupyter is a loose acronym meaning Julia
,
Python
, and R
. The word “notebook” denotes
documents that contain both code and rich text
elements, such as figures, links, equations, etc. Because of
the mix of code and text elements, these documents are the ideal place
to bring together an analysis description, and its results, as well as,
they can be executed perform the data analysis in real time.
Jupyter
is a free, open-source, interactive web tool
known as a computational notebook, which researchers can use to combine
software code, computational output, explanatory text and multimedia
resources in a single document. Jupyter is recommended by
Nature as data
scientists’ computational notebook of choice.
Jupyter
is installed along with
Anaconda
. Open
Anaconda Powershell Prompt (anaconda3)
, change working
directory using cd
.
Type and run jupyter notebook
. This will open your
default web browser, and Jupyter dashboard will show up.
Create a new note by clicking New
then
Python3 (ipykernel)
.
Go over User Interface Tour
under the
Help
tab to familiarize yourself with the layout.
Copy the following lines to a cell, run the cell, see what
happens. We will take a closer look at matplotlib
in the
future sections.
# import matplotlib
import matplotlib.pyplot as plt
# Get some data
temperatrue = [15.4, 16.3, 19.0, 22.7, 26.0, 28.0,
28.9, 28.7, 27.7, 25.3, 21.2, 17.0]
month = range(1,13)
# Plot a line
plt.plot(month, temperatrue)
# Add x and y labels
plt.xlabel("Month")
plt.ylabel("Temperature")
# Add figure title
plt.title("Monthly mean temperature in Shenzhen (degree)")
# Show plot
plt.show
Here are some further readings for Jupyter Notebook
: