笨办法学python习题6

1.注释程序

 1 # 给变量type_of_people赋值10
 2 type_of_people = 10
 3 # 在字符串里嵌入变量type_of_people,再赋值给x
 4 x = f"There are {type_of_people} types of people."
 5 
 6 # 把字符串"binary赋值给binary
 7 binary = "binary"
 8 # 把字符串"don't"赋值给do_not
 9 do_not = "don't"
10 # 在字符串里嵌入binary和do_not
11 y = f"Those who know {binary} and those who {do_not}."
12 
13 #打印x
14 print(x)
15 #打印y
16 print(y)
17 
18 #在字符串I said :后嵌入变量x,并且打印。
19 print(f"I said:{x}")
20 #在字符串后嵌入变量y,并且打印
21 print(f"I also said: '{y}'")
22 
23 #把"False"赋值给hilarious
24 hilarious = "False"
25 #把"Isn't that joke so funny?!{}"赋值给joke_evaluation
26 joke_evaluation = "Isn't that joke so funny?!{}"
27 
28 #在joke_evaluation的内容"Isn't that joke so funny?!{}"的{}里嵌入hilarious的值,并且打印
29 print(joke_evaluation.format(hilarious))
30 
31 #把字符串"This is the left side of..."赋值给w
32 w = "This is the left side of..."
33 #把字符串"a string with a right side."赋值给x
34 e = "a string with a right side."
35 
36 #把w和e的内容合并在同一行打印出来
37 print(w + e)

2.找出所有“把一个字符串放进另一个字符串”的位置

1 y = f"Those who know {binary} and those who {do_not}."
2 
3 print(f"I said:{x}")
4 
5 print(f"I also said: '{y}'")
6 
7 print(joke_evaluation.format(hilarious))

3.+这个操作符可以合并字符串(我猜的)

猜你喜欢

转载自www.cnblogs.com/shadowyuriya/p/9964455.html