Novice to learn the first day of Python

print ( "hello world")
variables: storage of information, the future is called, modify operation
constants: fixed amount, capital letters
naming rules:
1. Alphanumeric underscores
2. Do not start with a number and can not contain special characters space
3 is not named with the reserved word
4 can not be named Chinese
5. defined variables should meaningful
6. camel life, underlined word segmentation
7. variable names are case sensitive
a. 1 =
B 2 =
IF a <B:
Print ( "Yes")
Print ( "Yes")
Print ( "Yes")
Print ( "Yes")
the else:
Print ( "No")
A. 1 =
B 2 =

if a>b:
print("Yes")

elif a==b:
print("第三")

else:
print("any")


if Condition 1:
selfie
elif Condition 2:
jump
else:
dancing


# Single line comment
'' 'multi-line comment' ''
"" "multi-line comment" ""


input()


"abc" + "qwe"

file.py
file extension:
.py: Python program file
.txt: Text File
pdf chm html doc xml xls ppt


jpg png gif jpeg bmp
avi rmvb MP4 mkv 3gp
WMV MP3 flue mid

 

True true right
False false false


a
b = 100
c = 1000

if b <= a <= c:
print("True")

num number

num1 = intpu("Num1:")
num2 = intpu("Num2:")
num3 = intpu("Num3:")

Three digital output of the maximum / minimum

if num1>num2>num3:
#num1最大

else:
#num1<num2

 

if num1> num2> num3 # num1 largest
elif num1> num3> num2 # num1 largest
elif num2> num1> num3 # num2 largest
elif num2> num3> num1 # num2 largest
elif num3> num2> num1 # num3 largest
else

num3> num1> num2 # num3 maximum

num1 num2 num3

max_num =0

if num1>num2:
max_num= num1
if max_num > num3:
print("Max NUM is",max_num)
else:
print("Max NUM is",num3)
else:
max_num = num2
if max_num > num3:
print("Max NUM is",max_num)
else:
print("Max NUM is",num3)


num + = 1 + equivalent. 1 = NUM NUM
NUM - =. 1 is equivalent to NUM = NUM -. 1
NUM = 2 * equivalent to 2 * NUM = NUM
NUM / = 2 is equivalent to NUM = NUM / 2
NUM / / = 2 is equivalent to 2 // NUM = NUM
NUM = 2% is equivalent to 2% NUM = NUM
NUM = 2 ** equivalent num = num ** 2


and, and, and
only two conditions are all True (correct) when, as the result will be True (correct)


Condition 1 and Condition 2
. 5>. 3. 6 and <2 True


or or, or
as long as a condition is True, then the result is Ture,
. 5> or. 6. 3 <2
true or false

not No, Ya minute fly butterfly

not 5>3 == False
not 5<3 == True


a>b and (c>d or (not f))


(not (not True)) or (False and (not True))


Condition 1 and Condition 2
Condition 1 or Condition 2
shorted principles
for the first condition and, if the foregoing is false, then the calculation result of the expression before and after the two conditions and the composition will certainly false, the second condition will not calculated

Or for the
first condition is true the foregoing, the calculation result of the expression before and after the two conditions or composition will certainly be true, a second condition will not be calculated

 

True or True and False

 


Guess Age

 

 





height = int (input ( "Height :")) # user inputs a height
width = int (input ( "width :")) # user inputs a width

#num2 = height

The first step num2 height # =: assignment
while num2> 0: # Step two: num2 == 2

num1 = width # Step: assignment
while num1> 0: # fourth: num1 == 2 # Step Seven: = num1. 1
Print ( "#", End = "") # Step five: no new line an eighth step #: not a new line #
num1 - = 1 # step Six: num1 = ninth step 1: num1 = 0
Print () # step 10: just wrap
num2 - = 1 # eleventh step: num2 = 1

##
##

print("1*1=",1)

# "1*1=",1 == str(m)+"*"+str(n)+"=",1


m = 2
n = 2

Print (STR (m) + "*" + STR (n-) + "=", * n-m)



line = 5 Step #: assignment
while line> 0: # line = 5 second portion

tmp = line # third portion: tmp = tmp =. 5. 4

the while tmp> 0: # fourth: tmp = 5 # seventh step portion tmp = 4 # X: tmp = 3 = 2 thirteenth step tmp
Print ( "*", end = " ") # # fifth step # eighth portion eleventh portion fourteenth step #
tmp = tmp-1 # sixth step tmp = 4 # ninth step tmp = 3 # X step two steps tmp = 2. 1 fifteenth tmp =

Print ()
#Print (Line)
Line -. 1 =


First. 1 =
the while First <=. 9:

sec = 1
while sec <= first:
print( str(sec)+"*"+ str(first) +"="+str(sec * first), end="\t")
sec += 1


print()


first += 1



Guess you like

Origin www.cnblogs.com/daimagou/p/11825638.html