- 使用格式化輸出的三種方式實現以下輸出(name換成自己的名字,既得修改身高體重,不要厚顏無恥)
name = 'Nick'
height = 180
weight = 140
# "My name is 'Nick', my height is 180, my weight is 140"
name = 'Nick'
height = 180
weight = 140
print(f"My name is {name}, my height is {height}, my weight is {weight}")
print("My name is %s, my height is %s, my weight is %s"%(name,height,weight))
print("My name is "+name+ "my height is" +str(height)+"my weight is "+str(weight))
print("My name is {}, my height is {}, my weight is {}".format(name,height,weight))
2.整理《基本運算子》部落格,並給出url連結:
- 一行程式碼實現下述程式碼功能:
x = 10
y = 10
z = 10
print("x = {},y = {},z = {}".format(10,10,10))
- 兩種方式交換x和y的值:
x = 10
y = 10
- 一行程式碼取出該列表的第2、3個愛好:
nick_hobby_list = ['read','run','music','code']
nick_hobby_list = ['read','run','music','code']
,x,y, = nick_hobby_list
print(f'x:{x},y:{y}')