1、变量定义
a = 1 b = 'Hello World' c = True
2、条件判断
x = 10 if x > 5: print('x大于5') else: print('x小于等于5')
3、循环语句
for i in range(10): print(i) while x < 20: print(x) x += 1
1、数字
a = 1 b = 3.14 c = 1 + 2j
2、字符串
s1 = 'Hello' s2 = "World"
3、列表
list1 = [1, 2, 3] list2 = ['a', 'b', 'c']
4、元组
tuple1 = (1, 2, 3) tuple2 = ('a', 'b', 'c')
5、字典
dict1 = {'name': 'Tom', 'age': 18}
1、函数定义
def add(a, b): return a + b
2、模块导入
import math
标签: 站长圈