Hello World!

From Sustainability Methods
Revision as of 13:11, 13 September 2024 by Gustavo (talk | contribs) (Created page with "== Hello World == When learning a new programming language, normally we start with a simple “hello world” example. This one line of code will ensure that the environment i...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Hello World

When learning a new programming language, normally we start with a simple “hello world” example. This one line of code will ensure that the environment is set up correctly, and we know how to print a string.

print(’hello, world!”)

After executing the line above, you should see the Python prints hello, world! Yay!

Note: the “print ()” above is a function, and you passed the argument ‘hello, world!’ inside the print function to tell Python what to print. You just learned new keywords: function ("print()", argument("hello, world"), and statement (the whole line).

Comments

Besides writing code, it is always recommended to put a comment on your line of code. Not only that it helps other people to understand your code better, but more importantly it acts as a reminder for you of what you have written! Trust me, even experienced programmers will forget their lines of code after a few weeks.

To write comments in Python, use the hashtag symbol # before writing your comment. When you run your code, Python will ignore everything past the # on that particular line.

#Practice writing a comment
print (’hello, Eren’) #this prints my name
#print (’asdf’)