1. 程式人生 > 遊戲 >1998年特殊版“皮卡丘”寶可夢卡牌拍出90萬刀天價 打破拍賣紀錄

1998年特殊版“皮卡丘”寶可夢卡牌拍出90萬刀天價 打破拍賣紀錄

Python基本運算子

一、算術運算子

算術運算子不僅有加'+'減'-'乘'*'除'/',還有整除'//',取餘'%',等於'='。

print(9 // 6)
print(9 % 6)
print(9 + 6)
print(9 - 6)
print(9 * 6)
print(9 / 6)
print(9 == 6)

二、賦值運算子

  • 增量賦值
x = 100
x += 50  # :x = x + 50
print(x)
y = 100
y -= 50  # :y = y - 50
print(y)
z = 100
z *= 50  # :z = z * 50
print(z)
q = 100
q /= 50  # :q = q / 50
print(q)
  • 鏈式賦值
a = 999
b = a
c = a
print(a, b, c)  # :列印變數'a''b'''c'的值
a = b = c  # :簡化寫法
print(a, b, c)  # :列印變數'a''b'''c'的值
  • 交叉賦值
v = 3.141592653
w = 1234567890
tmp = v  # :建立一個臨時變數名'tmp'
v = w
w = tmp
print(v, w)
v, w = w, v  # :簡化寫法
print(v, w)
  • 解壓賦值
    分步解壓
student_height_list = ['175cm', '180cm', '177cm', '187cm', '190cm', '188cm', '185cm']  # :建立學生身高列表
student_height1 = student_height_list[0]
print(student_height1)
student_height2 = student_height_list[1]
print(student_height2)
student_height3 = student_height_list[2]
print(student_height3)
student_height4 = student_height_list[3]
print(student_height4)
student_height5 = student_height_list[4]
print(student_height5)
student_height6 = student_height_list[5]
print(student_height6)
student_height7 = student_height_list[6]
print(student_height7)


一步到位

student_height_list = ['175cm', '180cm', '177cm', '187cm', '190cm', '188cm', '185cm']  # :建立學生身高列表
height1, height2, height3, height4, height5, height6, height7 = student_height_list
print(height1, height2, height3, height4, height5, height6, height7)