Python video lecture 5 (notes and answers to exercises after class) and python lecture 5
Two days ago, I was lazy and didn't insist. I started today and hoped to stick to it,
Today we are mainly studying data types. For python, data types mainly include INTEGER (int), Boolean (bool), floating point (float), and E method (E)
For example, the integer (int) is mainly an integer, And the Boolean Type (bool) is judgment, true or false. Float contains the decimal point. The E notation is scientific.
There are several points to explain about the example:
1, type and isinstance. These two built-in functions are used to determine the type of a variable (integer or floating point type). The difference is that type mainly gives the type of a variable, and isinstance mainly judges the type of a variable.
2. For the bool type, as long as the value is not 0, all others are true,
3. the value in the integer (int) is truncated, that is
4. Use the E-note method. Pay attention to the error items in the example.
Hands-on part:
Import randomsecret = random. randint () I = 1 print ('-------------------- I love fish C studio ------------------') guess = 0 print ("guess which number the little turtle is thinking :") while (guess! = Secret) and (I <3): temp = str (input () I = I + 1 if temp. isdigit (): guess = int (temp) if guess = secret: print ("My grass, are you a worm in my heart ?! ") Print (" Hum, no reward even if you have guessed it! ") Else: if guess> secret: print (" brother, it's Big ~~~ ") Else: print (" Hey, small, small ~~~ ") Else: print (" You entered an error, please enter an integer: ") print (" the game is over, no play ^_^ ")