Home > database >  This how to do ah, in Python Python meowed small white online for help even draw flowcharts??
This how to do ah, in Python Python meowed small white online for help even draw flowcharts??

Time:11-15

Write a function, the system randomly generated within a 20 integers, allow the user to guess the size of the Numbers, if the number of randomly generated is greater than the user guesses, screen printing, "do you think small, the bigger the guess ~", if the generated number is less than the user guess the Numbers, screen printing "you guess, guess a little bit small, please ~", if just guess, screen printing "congratulations you guess!" , during this time, let the user guess a total of 5 times, if after 5 times guess there is still no right, then let program in D set to create a new "num. TXT" file, record the randomly generated Numbers, attention, to avoid the user input is not number of characters, need to use to catch exceptions, exception handling structure to catch exceptions, print "please input the correct number" and keep the user input, (hint: a random number with Python's built-in function)

CodePudding user response:

Listen to basic Python syntax ah, it is suggested that we can see some basic grammar video, Python source code to throw out
 import random 
Rand=random. Randint (0, 20)
For I in range (5) :
Inum=input (" please enter a number: ")
While not (inum isdigit ()) :
Print (" please input the correct number ")
Inum=input (" please enter a number: ")
If the int (inum) & lt; Rand:
Print (" do you think small, the big guess ~ ")
Elif int (inum) & gt; Rand:
Print (" you guess, guess a little bit small, please ~ ")
The else:
Print (" congratulations you guess!" )
Break
If I==4:
With the open (" F:/num. TXT ", "w") as F:
F.w rite (STR) (rand) # built-in file close function, this sentence doesn't need to write f. lose ()

CodePudding user response:

Thank you very much. Actually has a basic lesson, but a real fuck don't know how to start

CodePudding user response:

reference 1/f, sun flower reply:
basic Python syntax, listen to Suggestions can see video of some Python basic grammar, the source code to throw out
 import random 
Rand=random. Randint (0, 20)
For I in range (5) :
Inum=input (" please enter a number: ")
While not (inum isdigit ()) :
Print (" please input the correct number ")
Inum=input (" please enter a number: ")
If the int (inum) & lt; Rand:
Print (" do you think small, the big guess ~ ")
Elif int (inum) & gt; Rand:
Print (" you guess, guess a little bit small, please ~ ")
The else:
Print (" congratulations you guess!" )
Break
If I==4:
With the open (" F:/num. TXT ", "w") as F:
F.w rite (STR) (rand) # built-in file close function, this sentence doesn't need to write f. lose ()

Thank you very much. Actually has a basic lesson, but don't know how to start as soon as I get to use

CodePudding user response:

reference 1/f, sun flower reply:
basic Python syntax, listen to Suggestions can see video of some Python basic grammar, the source code to throw out
 import random 
Rand=random. Randint (0, 20)
For I in range (5) :
Inum=input (" please enter a number: ")
While not (inum isdigit ()) :
Print (" please input the correct number ")
Inum=input (" please enter a number: ")
If the int (inum) & lt; Rand:
Print (" do you think small, the big guess ~ ")
Elif int (inum) & gt; Rand:
Print (" you guess, guess a little bit small, please ~ ")
The else:
Print (" congratulations you guess!" )
Break
If I==4:
With the open (" F:/num. TXT ", "w") as F:
F.w rite (STR) (rand) # built-in file close function, this sentence doesn't need to write f. lose ()

Thank you very much. Actually has a basic lesson, but don't know how to start as soon as I get to use
  • Related