Print “Hello World”
The golden, first “baby walk” for beginners in learning every programming language is to output the string “Hello World”. In Python, it is simply done by the command print(<string>) as:
print("Hello World")
where print is the name of the command, followed by a pair of parentheses () which receives the argument(s)/input(s). The string has to be enclosed by a pair of quotation marks "". It should then produce the desired output:
Hello World
If you are using either Visual Studio Code or Google Colab, you can click the “play” button to execute the code snippet! Congratulations on your first Python line (and your environment is working properly)!
Exercise
Try to print your name and home city.
Suggested Solution
1.
print("Benjamin")print("Hong Kong")
2.
print("Benjamin", "Hong Kong")
What is the difference between these two ways?







Leave a Reply