Skip to content

Commit d92cd82

Browse files
Update hello_world.py
Add new print ways .
1 parent b13afe5 commit d92cd82

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

hello_world.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,34 @@
22
# it is normally used to if check everything is okay
33
import sys
44

5+
#type 1 sys.stdout.write()
56
sys.stdout.write("Hello, ")
67
sys.stdout.write("World!")
78
sys.stdout.write("\n")
9+
10+
#type 2 print()
811
print("Hello, World!")
12+
13+
#type 3 - format()
14+
15+
word1 = "Hello"
16+
word2 = "World"
17+
print("{} {}".format(word1, word2))
18+
19+
#type 4 - f-strings
20+
word1 = "Hello"
21+
word2 = "World"
22+
print(f"{word1} {word2} ")
23+
24+
25+
#type 5 - join
26+
characters = ['H','e','l','l','o',' ','W','o','r','l','d']
27+
message = "".join(characters)
28+
print(message)
29+
30+
#type 6 - Dict
31+
words = {"Eng_greeting": "Hello", "Eng_world": "World"}
32+
message = " ".join(words.values())
33+
print(message)
34+
35+

0 commit comments

Comments
 (0)