Mathematics, Sciences, and Technologies

“Every secret of a writer’s soul, every experience of his life, every quality of his mind is written large in his works.”
– Virginia Woolf

Python for Scientists 0-2: Running Your First “Hello World”

,

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

I’m Benjamin

Welcome to my Mathematical World! Here you can find posts and tutorials related to applied topics like Linear Algebra, Calculus, Differential Equations, as well as Programming. Feel free to leave comments and suggestions!

Let’s connect

Discover more from Benjamin's Maths World

Subscribe now to keep reading and get access to the full archive.

Continue reading