Question
CAN SOMEONE FIX MY CODE USING THE FOLLOWING RUBRIC? I WANT TO GET A 100 ON THIS ASSIGNMENT BELOW IS MY CODE from random import
CAN SOMEONE FIX MY CODE USING THE FOLLOWING RUBRIC? I WANT TO GET A 100 ON THIS ASSIGNMENT
BELOW IS MY CODE
from random import randint import os def play(): print(" \t::Guess Game::") name = input("Enter Name: ") num = randint(1,100) guess_left = 4 passed = False print("Hi ",name,"! Lets Play! ",sep='') while guess_left >0: guess = int(input("Guess("+str(guess_left)+" Tries Left): ")) if guess == num: print("Correct!") passed = True break elif guess>num: print("Too High!") else: print("Too Low!") guess_left -= 1 else: print("Failed! The Number was",num) print() if passed: save_high_score(name,guess_left) def save_high_score(name,score): highs =[] if os.path.isfile('highscore.txt'): fh = open('highscore.txt','r') highs = list(map(lambda x: x.strip(),fh.readlines())) fh.close() highs.append(str(score)+","+name) highs = sorted(highs,key=lambda x:x[1]) highs = sorted(highs,key=lambda x:x[0],reverse=True) fh = open('highscore.txt','w') for h in highs[:3]: fh.write(h+' ') fh.close() def show_high_score(): highs = [] if os.path.isfile('highscore.txt'): fh = open('highscore.txt','r') highs = list(map(lambda x:x.strip().split(','),fh.readlines())) fh.close() print(" \t::High Scores::") if len(highs)==0: print("No High Scores Yet!") else: print("Name\tScore") for h in highs: print('\t'.join(h[::-1])) def main(): while True: print(" Enter 1 to Play") print("Enter 2 to Check High Scores") print("Enter 0 to Exit") ch = input("Enter Choice(0-2): ") if ch =='0': break elif ch == '2': show_high_score() elif ch == '1': play() print() print("\t::THANK YOU:: ") if __name__ == '__main__': main()
BELOW IS RUBRIC
Below are the rubrics I will use to grade your two projects. Each project is worth 20% of your final course grade.
Programming Assignment 1 (Guessing Game)
__/25 points: Basically works
__/5 points: Comments with Name, Assignment, Date and basic explanation of what code does
__/5 points: Comments for sections in code as appropriate (roughly 3-5 comments on a program of this size)
__/5 points: User is given clear instructions on how to start and end the game
__/5 points: Reports tries for 1 game
__/5 points: User gets multiple guesses within a single round
__/5 points: Feedback to user on whether guess is High, Low, or Correct
__/5 points: Way for player to fail
__/10 points: Player can play multiple rounds of the game (e.g., Do you want to play again?)
__/10 points: High score kept and reported to user after each round
__/10 points: Store top 3 highest scores and player names in a file and report to user after each round
__/10 points: Check for correct input (e.g., What if a user types two as their guess?)
____ Subtraction of up to 3 points for magic numbers or files, or terrible variable names that
are confusing
I NEED TO BE ABLE TO COPY AND PASTE IT TO PYTHON!!!!!!!!! AND IT RUN PERFECTLY
THANK YOU!!!!!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started