"" "
A user logs in case
." ""
# Wait forever until the user enters a value
# variables
name_r = input ( "Please enter your user name")
passwd = the INPUT ( "Please enter your password:")
Print (name_r)
Print (passwd )
N1 = "root"
n2 = "the User"
Print (N1)
Print (n2)
"" "
variable can only have letters, numbers, underscores
can not start with a number, keyword can not use [ 'and', 'as' , 'assert', 'break' , 'class',' continue ',' def ',' del ',' elif ',' else ',' except ',' exec ',' finally ',' for ',' from ',' global ',' if ',' import ',' in ',' is ',' lambda ',' not ',' or ',' pass ','print ',' raise ',' return ',' try ',' while ',' with ',' yield ']
Do not python built things repeat
"" "
" ""
if the basic statement
if condition:
internal block
else :
internal code block
if support nested
if 1 == 1:
2 == 2 IF:
Print ()
the
else: . . .
the
else: . . .
elif IF
InP = the INPUT ( "Third Party hi"):
IF InP == "unable to receive":
Print
elif InP == "third party":
Pass
elif InP == "third party hi":
Pass
the else:
Pass
Print ()
Pass represents nothing execute
"" "
" ""
8 basic data type
string (quotes)
adding
n1 = "Caesar intended"
N2 = "Caesar intended"
N3 = N1 + N2
multiplication
n1 = "Caesar intended"
N2 = n1 * 10
digital
age = 13
add, subtract, multiply, divide, modulo, exponentiation
A1 = 10
A2 = 20 is
A3 = A1 + A2
A4 = A1 - A2
A5 = A1 * A2
A6 = A1 / 10
A7 A1% A2 = A1 # A2 taken // List
a8 = a1 ** a2
is determined parity
A = 13 is
TEMP = A 2%
IF TEMP == 0:
Print ( "O")
the else:
Print ( ". 1")
"" "
" ""
. 9 cycles
the while. 1. 1 ==:
Print (OK)
"" "
# output the while. 5. 4. 3 2. 6. 1. 9 10. 8
COUNT. 1 =
COUNT =. 11 the while:!
IF COUNT ==. 7:
Pass
the else:
Print (COUNT)
COUNT = COUNT +. 1
# 2, and find all the numbers 1-100
Numb = 0
TEMP = 0
the while Numb <= 100:
temp = numb +temp
numb = numb + 1
print ( "all numbers and 1-100:", TEMP)
TEMP)
# 1-100 output of all even
numb = 0
the while Numb <= 100:
TEMP = 2% Numb
IF TEMP == 0:
Print (Numb)
the else:
Pass
Numb Numb +. 1 =
# 1-100 Output in all odd
Numb = 0
the while Numb <= 100:
TEMP = 2% Numb
IF TEMP == 0:
Pass
the else:
Print (Numb)
Numb Numb +. 1 =
# 5, seeking 1-2 + 3-4 + 5. 99 .. All numbers and
Numb = 0
TEMP = 0
the while Numb <= 100:
T = 2% Numb
IF T == 0:
TEMP = TEMP - Numb
the else:
TEMP TEMP = + Numb
Numb Numb +. 1 =
Print ( "All the numbers and 1-100:", the TEMP)
# 6, the user login (three chances to retry)
# User : the root the passwd: 123456
count1 is = 0
the while count1 is <. 3:
INPUT = USER_NAME ( "Please Write your name:")
the passwd = INPUT ( "the passwd your:")
IF USER_NAME == 'the root' and the passwd == '123456':
Print ( "available for purchase in")
BREAK
the else:
Print ( " ! error agenin wirte ")
count1 count1 + = 1
# issue: 5 pence a rooster, a hen 3 penny, a penny chick 3, with 100 paper money to buy 100 chickens, which rooster, hen chicken must have asked rooster, hens, chicks just how many gather to buy 100 penny?
"" "
5 * cock <100
3 * hen <100
1 * chick <300
rooster chicks + hen + 1000 =
" ""
for G in Range (. 1, 21 is):
for m in Range (. 1, 34 is ):
for X in Range (. 1, 301):
Score G == 100 and IF + m + == 100 X:
Print ( '% s cock only,% s only hens, chickens only% s'% (g, m, x ))
The results demonstrate:
请输入用户名wqe
请输入密码:wqe
wqe
wqe
root
user
1
2
3
4
5
6
8
9
10
1-100的所有数的和: 5050
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
51
53
55
57
59
61
63
65
67
69
71
73
75
77
79
81
83
85
87
89
91
93
95
97
99
1-100的所有数的和: -50
please write your name:root
your passwd:qwewqe
error!agenin wirte
please write your name:root
your passwd:123456
welcome in
公鸡 4 只,母鸡 18 只,小鸡 78 只
公鸡 8 只,母鸡 11 只,小鸡 81 只
公鸡 12 只,母鸡 4 只,小鸡 84 只