forked from kal179/Beginners_Python_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello_world.py
More file actions
35 lines (25 loc) · 676 Bytes
/
Copy pathhello_world.py
File metadata and controls
35 lines (25 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# printing hello world is a tradition in beginners
# it is normally used to if check everything is okay
import sys
#type 1 sys.stdout.write()
sys.stdout.write("Hello, ")
sys.stdout.write("World!")
sys.stdout.write("\n")
#type 2 print()
print("Hello, World!")
#type 3 - format()
word1 = "Hello"
word2 = "World"
print("{} {}".format(word1, word2))
#type 4 - f-strings
word1 = "Hello"
word2 = "World"
print(f"{word1} {word2} ")
#type 5 - join
characters = ['H','e','l','l','o',' ','W','o','r','l','d']
message = "".join(characters)
print(message)
#type 6 - Dict
words = {"Eng_greeting": "Hello", "Eng_world": "World"}
message = " ".join(words.values())
print(message)