input-output condition determination cycle python

1, conditional
score = int (input ( "Please enter student achievement:")) 
IF Score> 100 and Score <0:
Print ( "Please enter the correct score")
elif Score <= 100 and Score> = 90:
Print ( "excellent" )
elif Score <90 and Score> = 80:
Print ( "good")
elif Score <80 and Score> = 60:
Print ( "pass")
the else:
Print ( "fail")


2, while loop

count = 0
COUNT the while <. 4: 
Print (COUNT)
COUNT = COUNT +. 1

# break cycle is ended immediately break is encountered
# continue cycling encountered in the present cycle ends continue
print ( '------------ ---------------- ')

Import Random
Number = the random.randint (1,100)
Print (Number)
COUNT = 0
the while COUNT <. 7:
GUESS = int (iNPUT ( "Please enter a a random number of 1 to 100: "))
COUNT = COUNT +. 1
IF gUESS> number:
Print (" big guess ")
elif gUESS <number:
Print (" guess small ")
elif gUESS == number:
Print (" guessed ")
BREAK
# IF COUNT = 7:!
# the Continue
# the else:
# Print (" run out of the number of errors ")
# Directly in the same level while adding else, after the end of normal while loop will execute else in the code directly
else:
Print ( "run out of the number of errors")


3、continue
number = 0
while number < 10:
number = number + 1
if number%2==0:
continue
print(number)

4, for cycle, print, output string
Import datetime
for I in Range (. 4):
Print ( "first", i + 1, "cycle", sep = "") #print plurality of connection must be used as a spacer sep Fu
Print ( "-----------------------")
# string formatting
username = 'linqian'
DATE = datetime.datetime.today ()
Print ( of the type (DATE))
# msg = 'welcome' + username + 'sign in' + 'today' + DATE
msg2 = 'Welcome to% s login, today is% s'% (username, DATE)
# Print (msg)
Print ( "-----------------------")
Print (msg2)

Guess you like

Origin www.cnblogs.com/lqcjlu/p/11371721.html