<> Problem description

Write function simulation guessing game . You can specify an integer range and the maximum number of guesses by parameters , The system randomly generates an integer within the specified range , The user is then asked to guess the value of the number , The system prompts players according to their guess ( for example , Guess big , Guess it's too small , That's right ), Players can adjust the next guess according to the system , Until you guess right or run out of times .

<> Implementation code
from random import randint def guess(start, end, maxTimes): value = randint(
start, end) for i in range(maxTimes): if i==0: prompt = 'Start to GUESS:' else:
prompt= 'Guess again:' try: x = int(input(prompt)) except: print('Must input an
integer between 1 and ', end) else: if x == value: print('Congratulations!')
break elif x > value: print('Too big') else: print('Too little') else: print(
'Game over. FAIL.') print('The value is ', value) guess(1, 10, 3)
<> Running results

©2019-2020 Toolsou All rights reserved,
Huawei 2021 session Hardware Engineer Logical post (FPGA) Super detailed surface !!!Vue-element-admin upgrade ui edition virtual machine VMware Download and install the most detailed tutorial !C++ Move constructor and copy constructor sound of dripping water java Backstage interview pygame Realize full screen mode and adjustable window size mysql Database setting character set configuration modification my.ini file (windows)30 What's the experience of being a junior programmer at the age of 20 C++ Multithreading programming ( Summary of common functions and parameters )python_ cherry tree