Currently this program will ask you which of two numbers is bigger. To get a higher grade i need to change it so that it is randomly asking which one is bigger or smaller. How would i edit my existing code to do this?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
while True : import sys import random user_name = input ( "Whats your name?" ) choice = input ( "{}, do you want to do custom or leveled difficulty?" . format (user_name)) if choice = = "custom" : custom_range_1 = int ( input ( "Pick a number to be the lowest." )) custom_range_2 = int ( input ( "Pick a number to be the highest." )) number_range = [custom_range_1,custom_range_2] first_custom_random = ( int (random.randrange(custom_range_1, custom_range_2))) second_custom_random = ( int (random.randrange(custom_range_1, custom_range_2))) print (first_custom_random, second_custom_random) user_anwser = input ( "Which is bigger, the first number or the second?" ) if user_anwser = = ( "2" ) and second_custom_random > first_custom_random: print ( "Correct!" ) elif user_anwser = = ( "1" ) and second_custom_random < first_custom_random: print ( "Correct!" ) else : print ( "Sorry thats wrong!" ) restart_choice = input ( "Do you want to restart?" ) if restart_choice = = ( "no" ): print ( "bye!" ) sys.exit([arg]) if restart_choice = = ( "yes" ): continue elif choice = = "leveled" : level_choice = input ( "Which level would you like? Pick 1, 2, or 3" ) if level_choice = = ( "1" ): points = 0 while points < 3 : leveled_range_1 = [ 1 , 100 ] level_1_random_1 = ( int (random.randrange( 1 , 100 ))) level_1_random_2 = ( int (random.randrange( 1 , 100 ))) print (level_1_random_1, level_1_random_2) user_anwser = input ( "Which is bigger, the first number or the second?" ) if user_anwser = = ( "2" ) and level_1_random_2 > level_1_random_1: print ( "Correct!" ) points + = 1 print ( "You have {} points" . format (points)) elif user_anwser = = ( "1" ) and level_1_random_2 < level_1_random_1: print ( "Correct! Thats 1 more point!" ) points + = 1 print ( "You have {} points" . format (points)) else : print ( "Sorry thats wrong!" ) points - = 1 print ( "You have {} points" . format (points)) continue print ( "LEVEL 2" ) level_choice = ( "2" ) if level_choice = = ( "2" ): points = 0 print ( "Begin level 2!" ) while points < 3 : level_2_random_1 = ( int (random.randrange( 1 , 1000 ))) level_2_random_2 = ( int (random.randrange( 1 , 1000 ))) print (level_2_random_1, level_2_random_2) user_anwser = input ( "Which is bigger, the first number or the second?" ) if user_anwser = = ( "2" ) and level_2_random_2 > level_2_random_1: print ( "Correct!" ) points + = 1 print ( "You have {} points!" . format (points)) elif user_anwser = = ( "1" ) and level_2_random_2 < level_2_random_1: print ( "Correct! Thats 1 more point!" ) points + = 1 print ( "You have {} points!" . format (points)) else : print ( "Sorry thats wrong!" ) points - = 1 print ( "You have {} points!" . format (points)) continue print ( "LEVEL 3!" ) level_choice = ( "3" ) if level_choice = = ( "3" ): points = 0 print ( "Begin level 2!" ) while points < 3 : level_3_random_1 = ( int (random.randrange( 1 , 10000 ))) level_3_random_2 = ( int (random.randrange( 1 , 10000 ))) print (level_3_random_1, level_3_random_2) user_anwser = input ( "Which is bigger, the first number or the second?" ) if user_anwser = = ( "2" ) and level_3_random_2 > level_3_random_1: print ( "Correct!" ) points + = 1 print ( "You have {} points!" . format (points)) elif user_anwser = = ( "1" ) and level_3_random_2 < level_3_random_1: print ( "Correct! Thats 1 more point!" ) points + = 1 print ( "You have {} points!" . format (points)) else : print ( "Sorry thats wrong!" ) points - = 1 print ( "You have {} points!" . format (points)) continue print ( "You won the game!!!!!!!!!!!!!!!!!!~!!!!!!!!!" ) restart_choice = input ( "Do you want to restart?" ) if restart_choice = = ( "no" ): print ( "bye!" ) sys.exit([arg]) if restart_choice = = ( "yes" ): continue |
Moderator nilamo: Please use code tags in the future