Guess, digital set an ideal example: 66, allowing users to enter a number, if larger than 66, the results show a big guess, then continue to allow user input; if less than 66, the results show a small guess, then continue to allow the user to enter; only equal to 66, show the correct guesses, then exit the loop.
while 1:
age=66
My_input = int(input('>>>'))
if My_input>age:
print('大了')
elif My_input<age:
print('小了')
else:
print('对了')
break
3 chances
On the basis of a question, setting: the user three guesses, if you guess right within three, the displays guess correctly, exit the loop, if there is no guessing correctly within three, the automatically exits the loop, and displays 'fool'
=. 1 CONT
the while CONT <. 4:
Age = 66
My_input = int (INPUT ( '>>>'))
IF My_input> Age:
Print ( 'large')
elif My_input <Age:
Print ( 'small')
the else:
print ( 'Yes')
BREAK
CONT. 1 + =
the else:
print ( 'fool')
Analyzing the following logic statements True, False
1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
8 or 3 and 4 or 2 and 0 or 9 and 7
0 or 2 and 3 and 4 or 6 and 0 or 3
6 or 2 > 1
6#2真前
3 or 2 > 1
0 or 5 < 4
5 < 4 or 3
2 > 1 or 6
3 and 2 > 1
0 and 3 > 1
2 > 1 and 3
3 > 1 and 0
3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2
While loop output 1234568910
conu = 1
while conu <11:
if the co
no == 7:
conu conu + 1 =
continue
print (conu)
conu + = 1
All numbers 1-100 and seek
s = 0
Account = 1
while account <101:
s + = Account
Account + = 1
print (s)
1-100 output all the odd (odd-remainder is divided by 2 1% 2 == 1)
conu = 1
while conu <101:
if conu% 2 == 1:
print (conu)
conu + = 1
1-100 output of all even (even number is divided by two the remainder is not 1)
conu = 1
while conu <101:
if conu% 2 == 0:
print (conu)
conu + = 1
Seeking the number of all + 1-2 + 3-4 and 5 ... 99
s=0#奇数
z=0
count=1
while count<100:
if count%2==1:
s=s+count
else:
z+=count
count+=1
print(s-z)#50
Description of ASCII, Unicode, utf-8 encoded in English and Chinese are a few bytes?
Description of the relationship between bits and bytes?
A byte 8 8bit = 1Byte bit is bit word, i.e. "0" Computer storage data "1", each "0", "1" is a word bit. Byte bytes, is the smallest unit of file storage, a byte consists of eight words bits, the top seven is the name of the file, the last digit is a check digit. 1Byte = 8bit, 1KB = 1024Byte, 1MB = 1024KB, 1GB = 1024MB, 1TB = 1024GB.
"Old Boy" use GBK accounted for a few bytes, use Unicode occupy a few bytes?
6,12
An upgraded version of the game to guess the age requirements: After allowing the user to try up to three times, each attempt three times, if you have not guessed, it age = 66, if the answer Y, it is allowed to continue to guess three times, this back and forth, if the answer N , you exit the program, you guessed how will exit.
count=1 age=66 while count<4: My_input = int(input('>>>')) if My_input>age: print ( '% s you have a big chance'% (3-count)) elif My_input<age: print ( '% s you have a small chance'% (3-count)) else: print ( 'yo for the big guy') break count+=1 if count==4: zz = input ( 'y n Xiaoxuming exit') if zz.upper()=='Y': count=1 if zz.upper()=='N': break
Using the user input START ⼀ a number is judged whether the number is a number ⼀ (upgrade title) quality.
# Prime number, also known prime number is divisible only by 1 or their own natural number. # But not more than the number of large prime numbers we call composite number 1, 1 and 0, that is, non-prime nor composite number # Smallest prime number is 2, and the largest prime number does not exist, it has proved Euclid in his "Elements" in
num = int (input ( "! Please enter a number"))
I = 2
IF NUM> = 2:
the while I <NUM:
IF NUM% I == 0:
"! The number you entered% s not a prime number" print ( % (NUM))
BREAK
the else:
I + =. 1
the else:
Print ( "the number you entered is a prime% s!"% (NUM))
the else:
Print ( "input error!") a = iNPUT ( '>>> ') IF A == == 0. 1 or A: Print (' not ') ! elif a.isdecimal () and int (A) = int. 1 and (A) = 0:! Print (' a ') the else: print ( 'not')
a=input('>>>')
if '最' or '第一' in a:
print('bux')
eles:
print('s')
START ⼀ input number. This number is determined to get accustomed bits (Using the algorithm) (Upgrade title)
a=input('>>>')
print(len(a))