我正在写我的第一份作业,我似乎无法弄清为什么我无法进入我的第一份工作

时间:2018-12-04 07:49:25

标签: python-3.x

首先,我很抱歉用一堆代码轰炸我的帖子,但我希望将其放在这里,希望它可以帮助你们更好地理解我的问题。

我试图弄清楚为什么我的IDE不愿执行代码的第一个功能。显然我是在做错事,但是我是没有经验的人自己看。所有帮助将不胜枚举。

如果您对我的代码有任何其他评论或提示,请随时贡献。

import random

print("Press '1' for New Single Player Game - Play against computer component: ")
print("Press '2' for New Two Player Game - Play against another person, using same computer: ")
print("Press '3' for Bonus Feature - A bonus feature of choice: ")
print("Press '4' for User Guide - Display full instructions for using your application: ")
print("Press '5' for Quit - Exit the program: ")

def choose_program():
    what_program = int(input("What program would you like to initiate?? Type in the 'number-value' from the chart above: "))
    if what_program == 1 or 2 or 3 or 4 or 5:
        program_choice = int(input("Make a choice: "))
        if (program_choice > 5) or (program_choice < 1):
            print("Please choose a number between 1 through 5 ")
            choose_program()
        elif program_choice == 1:
            print("You picked a New Single Player Game - Play against computer component")
            def single_player():
                start_game = input("Would you like to play 'ROCK PAPER SCISSORS LIZARD SPOCK'?? Type 'y' for YES, and 'n' for NO): ").lower()

                if start_game == "y":
                    print("Press '1' for Rock: ")
                    print("Press '2' for Paper: ")
                    print("Press '3' for Scissors: ")
                    print("Press '4' for Lizard: ")
                    print("Press '5' for Spock: ")

                elif start_game != "n":
                    print("Please type either 'y' for YES or 'n' for NO: ")
                    single_player()

            def player_one():
                human_one = int(input("Make a choice: "))
                if (human_one > 5) or (human_one < 1):
                    print("Please choose a number between 1 through 5 ")
                    player_one()
                elif human_one == 1:
                    print("You picked ROCK!")
                elif human_one == 2:
                    print("You picked PAPER!")
                elif human_one == 3:
                    print("You picked SCISSORS!")
                elif human_one == 4:
                    print("You picked LIZARD!")
                elif human_one == 5:
                    print("You picked SPOCK!")
                return human_one

            def computers_brain():
                cpu_one = random.randint(1, 5)
                if cpu_one == 1:
                    print("Computers choice iiiiiis ROCK!")
                elif cpu_one == 2:
                    print("Computers choice iiiiiis PAPER!")
                elif cpu_one == 3:
                    print("Computers choice iiiiiis SCISSORS!")
                elif cpu_one == 4:
                    print("Computers choice iiiiiis LIZARD!")
                elif cpu_one == 5:
                    print("Computers choice iiiiiis SPOCK!")
                return cpu_one

            def who_won(human, cpu, human_wins, cpu_wins, draw):
                if human == 1 and cpu == 3 or cpu == 4:
                    print("Human is invincible!!")
                    human_wins = human_wins.append(1)
                elif human == 2 and cpu == 1 or cpu == 5:
                    print("Human is invincible!!")
                    human_wins = human_wins.append(1)
                elif human == 3 and cpu == 2 or cpu == 4:
                    print("Human is invincible!!")
                    human_wins = human_wins.append(1)
                elif human == 4 and cpu == 2 or cpu == 5:
                    print("Human is invincible!!")
                    human_wins = human_wins.append(1)
                elif human == 5 and cpu == 1 or cpu == 3:
                    print("Human is invincible!!")
                    human_wins = human_wins.append(1)
                elif human == cpu:
                    print("Human & computer think alike, such technology")
                    draw = draw.append(1)
                else:
                    print("Computer have beaten it's master, incredible..")
                    cpu_wins = cpu_wins.append(1)
                return

            def end_score(human_wins, cpu_wins, draw):
                human_wins = sum(human_wins)
                cpu_wins = sum(cpu_wins)
                draw = sum(draw)
                print("Humans final score is: ", human_wins)
                print("Computers final score is: ", cpu_wins)
                print("Total draws: ", draw)

            def main():
                human = 0
                human_wins = []
                cpu = 0
                cpu_wins = []
                draw = []
                finalhuman_wins = 0
                finalcpu_wins = 0
                finaldraw = 0
                Continue = 'y'
                single_player()
                while Continue == 'y':
                    human = player_one()
                    cpu = computers_brain()
                    who_won(human, cpu, human_wins, cpu_wins, draw)
                    Continue = input("Would you like to play again (y/n):").lower()
                    if Continue == 'n':
                        print("Printing final scores.")
                        break
                end_score(human_wins, cpu_wins, draw)

            main()
        elif program_choice == 2:
            print("You picked a New Two Player Game - Play against another person, using same computer")
        elif program_choice == 3:
            print("You picked the Bonus Feature - A bonus feature of choice")
        elif program_choice == 4:
            print("You picked the User Guide - Display full instructions for using your application")
        elif program_choice == 5:
            print("You picked to Quit - Exit the program")
        return program_choice
    elif what_program != 1 or 2 or 3 or 4 or 5:
        print("To initiate a program you need to type in the appropriate number to initiate this program, either 1, 2, 3, 4 & 5 ")
        choose_program()

在IDE中出局:

Press '1' for New Single Player Game - Play against computer component: 
Press '2' for New Two Player Game - Play against another person, using same computer: 
Press '3' for Bonus Feature - A bonus feature of choice: 
Press '4' for User Guide - Display full instructions for using your application: 
Press '5' for Quit - Exit the program: 

Process finished with exit code 0

在此先感谢您的帮助:)

0 个答案:

没有答案