Home > other >  Bosses look is what code to run after, grateful (?????? Omega?? )?
Bosses look is what code to run after, grateful (?????? Omega?? )?

Time:02-09

Import the random
# start module -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Def start () :
Name=input (' input user name:)
If name=='3' :
Return
If the name not in hisroty:
Hisroty [name]=[]
Module # history -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Def show_history () :
The history={}
For the name, the data in the history. The items () :
Print (' user: {}, records are as follows: {} '. The format (the name, data))
Def dafault () : # prevent input without options
Print (' input error! Please input again ')
Print ('='* 40)
If __name__=="__main__ ':
Select_dict={' 1 ': start,' 2 ': show_history,' 3 ': exit}
While turn:
Select=input (' 1, start the game \ n2, history \ n3, withdrew from the games \ n ')
Select_dict. Get (select, default) ()
Core module # -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Def try_to_guess (name, answer) :
Answer==random. Randint (0102)
Try_num=0
While try_num & lt; 10:
Guess_answer=int (input (' please enter a number:))
If guess_answer & lt; Answer:
Print (' you input number is smaller than the right answer)
Elif guess_answer==answer:
Print (' correct answer! ')
The history [name]. Append (' success ')
Break
The else:
Print (' you input number is larger than the right answer)
Try_num +=1
The else:
Print (' guess wrong too many times, failed)
The history [name]. Append () 'failure'

CodePudding user response:

Don't say function content, call?
  • Related