Good morning,
I work for a Federal Defender office. We represent clients who have been charged with a federal crime and can’t afford to defend themselves. We have a client serving a life sentence who is learning to code in Python. It is really his passion and the only thing that keeps him sane at times. I was wondering if someone could paste his code into Python and let me know if there are any errors? Python is beyond my abilities…I am just a system admin. Thank you in advance. It is for a good cause.
… py3
with open (“rockpapscis.txt” “w”) as f:
import random
opt_set =4"Rock", “Paper”, “Scissors,.
opt_list = [“Rock”, “Paper”, “Scissors”]
pl_dic = ?Rock, Scissors”: “Rock Beats Scissors”, “Paper, Rock”: “Paper
Beats Rock”, “Scissors, Paper”: “Scissors Beat Paper”
cpdic =.t"Scissors Rock": “Rock Beats Scissors”, “Rock, Paper”: “Paper
Beats Rock”, "Papleir, Scissors: “Scissors Beat Paper”).
texts = ["Player Wine, “Computer Wins”, “Draw”, “Game”]
num = 1
plwins = 0
cpwins = 0
draws = 0
choices =
pl_choice = " "
while num < 6:
print(text[3] + + num)
inner_loop = True.
while inner_loop 7= True:
pl_choice = input(“Enter your selection: Rock, Paper or Scissors”)
if pl_choice in, ?pt_set == False:
print(“Incorrect entry. Try again.”)
else:
inner_loop = False
cp_choice = randomichoice(opt_list)
choices.extendapLchoice, cp_choice])
print(“Player has Chosen + " " + pl_choice + 1, + tt + “Computer has
chosen” + " " + Cp_choice + “.”)
for pl_key in pl_dic.keys():
if choices !=
for cp_key initp_dic.keys():
if choices == cp_key:
win = cp_dlc[choices]
print(win)
print(texts[1])
cp_wins += 1
1
num += 1
elif choices -= pl_key:
win = pldic[choices]
print(win)
print(texts[0])
pl_wins += 1
num ±= 1
else:
print(texts[2])
draws += 1
num += 1
print(“Game Over”)
print(“Player has” 4- /7 pl_wins + " " wins.)
print(“Computer has” + If It + cpwins + " " + wins.)
print(“T It It here are” + draws + “draws”)
if plwins > cR_wins
print(texts[0) + pl_wins + cR_wins + draws)
if pl_wins < cp_wins :
print(texts[1] + + plwins + draws)
else:
print(“Series was a draw”)
with open (“beersong.txt” “w”) as f:
bn = 99
nn = 98
v = [ bottles”, “of beer on the wall.”, “of beer. Take one down. Pass it
around.”, “bottle” “There’s no more bottles of beer on the wall.”]
while bn > 2: I
print(bn + " " + v[O] + " " + v[1] + " " + bn + " " + v[0]+ " " +
v[2] + u " + nn + " " + v[O] + " " + v[1])
bn -= 1
nn -= 1
if bn == 2:
print(bn + " it + v[0] + 31 II + v1.11.1
It II
- bn + r II II + v[0] + " n v[2] +
II It + nn + " " + v[3] + " II + v[1])
bn -= 1
nn -= 1
if bn == 1:
print(bn + " "t, v[3] + U U + v[1] + " " + bn + " " + v[3] +
v[2] + " " + v[4])
II II
C 3
with open (“conversion.text” “w”) as f:
def temp_conversion (degrees, scale):
if scale == Fahrenheit:
Celsius = (degrees - 32) * 5/9
Kelvin = Celsius + 273.15
print(Celsius + “C”)
print(Kelvin + “K”)
if scale == Celsius:
Fahrenheit = (degrees + 32) * 9/5
Kelvin = degrees + 273.15
print(Fahrenheit + “°F”)
print(Kelvin + “K”)
…