python基础
-- coding: utf-8 --
“”"
Created on Sat Dec 25 20:39:07 2021
@author: wang
“”"
打印输出
print(1)
print("i 'am superman")
print('apple'+'car')
print('apple'+str(4))
print(1+2)
print(float(1.2)+2)
运算符
a=2**4 # 2的4次 #
b = 8%2 # 8除以2的余数
c= 9//2 # 9除以2的整数结果
print(a)
apple=1
e,f,g=2,3,4 #
print(a,b,c)
循环
condition=1
while condition<10:
print("condition",condition)
condition=condition+1
while True:
print("i am true")
break
example = {1,2,3,4,5,6,7,8,9,10}
for i in example:
print(i)
print("inner of for")
#for wind
for j in range(1,100,10): ##1-99 10为步距
print(j)
print("outer of for")
判断
x=1
y=2
z=0
m=0
if x<y>z:###x<y && y>z
print("x<y")
if z==m:
print("z=m")
if x>y:
print("x>y")
else:
print("x<y")
if x>y:
print("x>>y")
elif x>z:
print("x>>z")
else:
print("==")
函数
def function():
print("function")
a=1111
b=2345
c=a+b
print(c)
function()
def fun(a,b):
print("a",a)
print("b",b)
c=a*b
print("the c is",c)
fun(10000, 5)
fun(a=100, b=a)#a=16 赋值给b