Lab 1: Hello WorldΒΆ

Work through the following exercises and reflection questions. For credit on the lab, you only have to submit a very simple "Hello world!" program at the end of the lab, but the rest will help you in future labs and quizzes.

For each of the reflection questions, discuss with your group and write answers in your notes.

Exercise 1: Run this line of code (as a script or in the interactive shell):

print('Hello')
  • Is there a difference between 'Hello' and "Hello"?

Exercise 2: What happens when you run each of the following lines?

print("Isn't it a nice day out?")
print('Isn't it a nice day out?')
  • Why did the second one give you an error?
  • Why do you think Python allows you to use both " and '?
  • How can you get a " symbol to print?

Exercise 3: The following print statement contains text with a special symbol, \n, that does something strange.

print("here is some text\nhere is more text")
  • \n is called the newline character. Why do you think it is called that?

Exercise 4: There are other special characters too. Experiment with these: \t and \\

  • What do each of these do?
  • Why do you think it is necessary for Python to support special text characters like these?

Challenge Exercise: For the points on this lab, write a Python program which displays the message "Hello world!". When you run it in Thonny, it should look like this:

When you are finished, upload your .py file to the codePost Hello World assginment.