Two days ago lazy, did not insist, today began, hope can persist,
Today the main learning is the data type, about Python, the data type is mainly integer (int), Boolean type (bool), floating-point (float), e notation (e)
As an example, an integer (int) is mostly integers, and a Boolean type (BOOL) is judged, true, or false. Float (float) contains the decimal point, and the e notation is the scientific counting method.
For examples, there are a few points to note:
1,type and Isinstance. This is a two built-in function, these two main functions are to determine the type of variables (integer, float, etc.), the difference is that type is mainly given the types of variables, isinstance is mainly the type of the judgment variable.
2, about the bool type, as long as its value is not 0, the others are true,
3. The value in integer (int) is truncated, i.e.
The use of 4.E notation, note the error in the example.
Hands-on section:
Import Randomsecret= Random.randint (1,Ten) I=1Print ('------------------I love fish C studio------------------') Guess=0Print ("guess which number the turtle is thinking now:") while(Guess! = secret) and (I <3): Temp=str (input ()) I= i +1 iftemp.isdigit (): Guess=int(temp)ifGuess = =Secret:print ("I grass, you are a small turtle in the heart of the worm?! ") Print ("Well, there's no reward for guessing! ") Else: ifGuess >Secret:print ("elder brother, Big has been big ~ ~ ~") Else: Print ("Hey, small, small.") Else: Print ("you entered the error, please enter an integer:") Print ("game Over, no play ^_^")
Little Turtle Python Video V (Notes and after-class exercise answers)