Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 872 Bytes

File metadata and controls

40 lines (27 loc) · 872 Bytes

Task 1 - Hello World

Before doing anything else in a new programming language, you traditionally make it say “Hello world”. In Python that’s a one-liner:

print("Hello world")

The print() function sends whatever you give it straight to the console.


Repeating output

You can ask Python to repeat a string by multiplying it:

print("example " * 5)

That prints one line containing the word example five times.


Your exercise

  1. Create a new file called Task_1.py in your editor.
  2. Write the lines shown below.
  3. Run the file from your terminal or IDE and watch the output.
print("Hello world")
print("example " * 5)

Hint: Text must always be wrapped in quotes (' ' or " "). Forgetting them makes Python think it’s a variable name and you’ll get an error.