This is the classic first step to programming in a new language. Fortunately, in Python, printing "Hello World" is quite intuitive. Start with a new file and type the following code.
When you run the module, "Hello World" gets printed to the shell.
--------------------------------------------------------------------------------------------------------------------------
Python's ease of use and intuitive coding structures allow you to write code directly in the shell as well, so when I first tried accomplishing the "Hello World" program, before consulting any sources, I did the same thing entirely in the shell, no extra files or Run Module buttons to click. I wrote the code, and hit enter. That's all!
And it worked! That's the beauty behind the simplicity of coding in Python.
Source:
https://www.youtube.com/watch?v=bE8VEFdvG_E
You post highlights a very key point in using Python - the difference between writing a function and interpreted execution. The first example you showed us was with a written function and the second was interpreted. However, for those not familiar with the differences and do not have a Python environment in front of them, the significance might be lost. It should become clear when you write programs that are more than one line long.
ReplyDeleteIn languages like C# and Java, single quotes encode a single character while double quotes encode a string of multiple characters. Is there a difference between single and double quotes in Python?
ReplyDeleteTechnically speaking, single and double quotes are the same in Python. Stylistically, there may be cases where it makes sense to use one or the other depending on personal preference or the style of a community of coders with which you work, but the functionality is the same.
Delete