python教程 基础语法

Last updated on September 15, 2024 pm

🧙 Questions

python基础语法

☄️ Ideas

打印

x=1
y=2
print('hello world')
print('x is {} and y is {}'.format(x, y))

判断

if not 1>2:
	print('ok')
else:
    print('error')

遍历

peoples=['zhangsan','lisi','wangwu']

peoples.append('zhaoliu')
peoples.remove('lisi')

for people in peoples:
	print(people)

循环

i=0
while i<5:
	print(i)
	i=i+1

函数

def add(x, y):
    print("x is {} and y is {}".format(x, y))
    return x + y  

print("result is {}".format(add(1,3)))

python教程 基础语法
https://ispong.isxcode.com/pytorch/python/python教程 基础语法/
Author
ispong
Posted on
March 24, 2022
Licensed under