Python

Programming

Lesson 1 - Input & Output

Task 1 - Hello World

In the programming trinket to the left, type the following code:

print("Hello World")

Click the play icon to run the code and see what it does.

Now open the assignment on Google Classroom called Task 1 - Hello World.

Change the code in the trinket and make a note in the document of what happens when you change the code.

Task 2 - Asking Questions

Now you are going to create a program so that it uses input to ask the user questions and then respond to these questions using the information by using print.

  1. Type the following code in the trinket below to create an input that will ask the user to enter their name, it will store the response in the variable answer:

answer = input("Enter your name: ")

2. Now the user has typed in their name add the following code to print the information on screen that says hello and greets them with their name:

print("Hello " + answer + " how are you today?")

IMPORTANT: Look at how text that doesn’t change is in “” speech marks and it is joined together with the variable that stores the answer using + signs.

3. Test your program, it should work like the example shown to the right.

Extension

Copy and paste the two lines of code you have just written and change the input and print to ask the following questions and respond:

  1. How old are you?

  2. What is your favourite hobby?

  3. What is your favourite subject?

  4. Where do you live?

An example of what the program could do like when run is shown to the right.

Evidence point

Open the Assignment in Google Classroom called Student Evidence - L1 - Input Output.

Take a screenshot of your code for:

  • Task 1 - Hello World

  • Task 2 - Asking Questions

For each program click on Share and choose Link. Copy the link and paste it into the document, this means you can come back to it in future lessons.