请登录后探索更多精彩内容!
# 定义一个整数类型的变量 age = 20 # 定义一个字符串类型的变量 name = "John" # 定义一个浮点数类型的变量 height = 1.75
# 布尔值 is_student = True # 列表,可包含不同类型的数据 fruits = ["apple", "banana", 3.14] # 元组,不可变的序列 coordinates = (10, 20) # 集合,无序且不包含重复元素 numbers = {1, 2, 3, 3} # 字典,以键 - 值对的形式存储数据 person = {"name": "Alice", "age": 25, "city": "New York"}
a = 10 b = 3 print(a + b) print(a - b) print(a * b) print(a / b) print(a % b) print(a ** b) print(a // b)
x = 5 y = 7 print(x == y) print(x!= y) print(x > y) print(x < y) print(x >= y) print(x <= y)
p = True q = False print(p and q) print(p or q) print(not p)
score = 85 if score >= 90: print("优秀") elif score >= 70: print("良好") else: print("合格")
fruits = ["apple", "banana", "cherry"] for fruit in fruits: print(fruit)
count = 0 while count < 5: print(count) count += 1
def add_numbers(a, b): return a + b
result = add_numbers(3, 5) print(result)
print("Hello, World!") name = "Bob" age = 30 print("姓名:", name, "年龄:", age)
暂无评论
请先登录后发表评论!
暂无评论