On the third day?

Python string?
Single quotes with a bunch of single quotation marks text containing up
Double quotes a bunch of double quotation marks text containing up
Triple quoted
these three forms? Double or single quotes must pairs = - =

Python is a branched structure key else if elif
example: a = float (input ( "Enter Results:"))
IF A> = 90:
B = 'A'
elif A> = 80:
B = 'B'
elif A > = 70:
B = 'C'
elif a> = 60:
B = 'D'
the else:
B = 'E'
Print ( 'corresponding to the levels are:', b)
of the cyclic structure: Python for two cycles are and -in the while
for-loop in the example:
SUM = 0
for X in range (101):
SUM = X +
Print (SUM)
range (101) in this example is expressed as a range from 0 to 100
range (101) can generate a sequence of integers 0 to 100
range (1,100) generating a sequence of integers 1 to 99
range (1,100,2) can generate a sequence of odd-numbered 1 to 99, this represents a 2 is the step size i.e. the amount of increase in the number sequence
while loop: while loop can be generated by a transform an expression bool worth control loop cycle time is obtained when the value of the expression is True, False have time for the end of the loop
can be using while loops have to do a simple guessing game
import random # in Python since then random () This is the need to use this line of code can not be directly accessed by references random () method

answer = random.randint (1, 100) # This line of code is called the answer to declare a random number 1-99 of the
counter = 0 #counter a start value of 0 indicates the will, but every time you guess wrong because +1 in this line of code there is counter + = 1 so this is so wow
the while True:
counter + = 1
Number = int (iNPUT ( 'enter:'))
IF Number <answer:
Print ( 'larger')
elif Number> answer:
Print ( 'smaller')
the else:
Print ( 'Congratulations, you guessed it!')
BREAK
Print ( 'have you guess% d times'% counter)
IF counter> 7:
Print (' your IQ balance significantly insufficient')

Number of daffodils Python:
for NUM in Range (100, 1000):
Low 10% NUM =
MID NUM = 10 // 10%
High NUM = 100 //
IF NUM == + MID. 3 ** ** Low + High. 3 3 **:
Print (NUM)

 

Wow! Today all the code, I cracked wow

Guess you like

Origin www.cnblogs.com/linQingxuan/p/11863614.html
Recommended