Skip to content
← Back to Community
Python Penalty Shootout Tutorial
Profile icon
Codeye

Python Penalty Shootout Tutorial
By @CodeyeJR
So, at the start of the python script we would use
This file cannot be displayed: https://storage.googleapis.com/replit/images/1540222204295_1e365477df2ec40968a47bfcd1b099db.pn
so that we can use the random package later on in the script.
Then we should define the options for where the goalkeeper can save the ball for this we should use
This file cannot be displayed: https://storage.googleapis.com/replit/images/1540222216746_e8b02ba15b0c9ed6143e4586aa457ccc.pn
this defines what the goalkeeper can choose from.
Then we should decide where the goalkeeper should block by using
This file cannot be displayed: https://storage.googleapis.com/replit/images/1540222346578_4b3214d84f876c6c91cbb3db2a8fd0b1.pn
this will decide where the goal keeper should block so we can compare it with the players shot.
Then we should decide whether the person who is taking the shot should miss for this we will use
This file cannot be displayed: https://storage.googleapis.com/replit/images/1540222358870_3c8f6c51909d615a55abc01afe3be49d.pn

.
Now we will ask where the user wants to shoot for this we are going to use
This file cannot be displayed: https://storage.googleapis.com/replit/images/1540222367729_0e27d5d6b9790d758a8959b3dfd35c95.pn
so we can ask the person where they want shoot and receive their input and save it to the variable shoot.
Next we are going to check whether the User’s shot has been saved by the goalkeeper for this we are going to use an if statement and we are going to write this
This file cannot be displayed: https://storage.googleapis.com/replit/images/1540222389553_6549960c82a8b08f99b18b3c21615ded.pn
. This will ask the program if the user’s input matches where the goalie is going to save and if it is then it will tell the user that the goalkeeper has saved it.
Then we are going to check if the user has missed if they have gotten past the goalkeeper for this we are going to do
This file cannot be displayed: https://storage.googleapis.com/replit/images/1540222430771_e68139cfa986067809694e409c514220.pn

This will ask the program if the user has a missed stat of 1 and if it is they will show the message that they have missed.
Now if the User has gotten past both the goalkeeper and the chance of missing they will have scored so then we will do this
This file cannot be displayed: https://storage.googleapis.com/replit/images/1540222473894_6704f114405651e44def48fe22ca5222.pn

This will send the user the message to tell them that they have scored if they didn’t miss or the goalkeeper didn’t save it in the end your code should produce something like this
This file cannot be displayed: https://storage.googleapis.com/replit/images/1540222487658_67f4785175c57eafb5ce63a0c99ecad1.pn
Or
This file cannot be displayed: https://storage.googleapis.com/replit/images/1540222495607_b29e14c7c73876466b4adf4f6d147c0b.pn

Or even like this
This file cannot be displayed: https://storage.googleapis.com/replit/images/1540222506920_7197074b98dc290cbcd21d615a333442.pn

Thank you for reading my tutorial

Voters
Profile icon
GianLucca3
Profile icon
Afonso-Costa-eC
Profile icon
teacherhei2023
Profile icon
keenanmercer
Profile icon
Codeye
Comments
hotnewtop
Profile icon
[deleted]

:D