Python print with variable - Google Search
以下全て同じ文字列を出力します.出題者の意図を汲み取って適切なものを利用してください.
python
1def hello1(name):
2 print(f"こんにちは{name}さん")
3
4def hello2(name):
5 print("こんにちは{}さん".format(name))
6
7def hello3(name):
8 print("こんにちは{0}さん".format(name))
9
10def hello4(name):
11 print("こんにちは%sさん" % name)
12
13def hello5(name):
14 print("こんにちは", name, "さん", sep = "")
15
16def hello6(name):
17 print("こんにちは", end = "")
18 print(name, end = "")
19 print("さん")
20
21def hello7(name):
22 print("こんにちは" + name + "さん")
23
24def hello8(name):
25 output = "こんにちは"
26 output += name
27 output += "さん"
28 print(output)
29
30def hello9(name):
31 print(name.join([''.join(list(map(chr, [12371, 12435, 12395, 12385, 12399]))), "さん"]))
32
33def hello10(name):
34 output = list("こんにちはさん")
35 output.insert(5, name)
36 print(''.join(output))
37
38def hello11(name):
39 for s in [12371, 12435, 12395, 12385, 12399, 12373, 12435]:
40 print(chr(s), end = "")
41 if chr(s) == "は":
42 print(name, end = "")
43 print()
44
45for i in range(1, 12):
46 print(f"hello{i}(name): ", end = "")
47 globals()[f"hello{i}"]("キティ")
paiza.io