Before you start this course, you must login to Replit

If you have forgotten your Replit account user name or password, ask your Coder Coach.


# 3-3-Modify

Task – Modify


The code should be modified to:

  • Combine the line ‘Do you like programming’ and the line ‘answer = input’, so that the input has a prompt in it.

  • On the second to last line, print a sentence that includes both the name and the answer variables.

  • Add comments (use #) to explain what you have changed.

  • CHALLENGE: Make the program assign input into the ‘name’ variable. Do this by putting a prompt in the input command to ask the user for their name.

Learning Objectives/Goals

Students will learn to interpret, trace, identify and create python code that uses:

Concept Explanation Python Code Examples
Strings The text data type. All string data is treated as text, even if it is numerical characters. “string goes here” “This is a string”
Variable assignment Putting data into a variable. = num1 = 10 name = “Andy”
Concatenation Joining string literals (text in speech marks that prints exactly as it appears in the code) to the contents of variables in output, or joining the contents of variables together. There are several ways of doing this, but I’ve used the plus symbol in my exercises. + print(“Hello ” + name) fullName = firstName + lastName
Input Collecting data for processing. In these examples we collect input that the user types on the keyboard but computers collect input in lots of ways – as sound, mouse movements, with sensors etc. Input must ALWAYS be assigned to a variable or it will not be stored. All input is treated as strings. Any input that needs to be treated as a number must be cast into the new format. variableName = input() print(“What’s your name?”) name = input() print(“Guess the secret number”) guess = int(input())

What is input?

Need more help with input? click here

Prior learning

  • Variable assignment – Using the ‘=’ symbol to store data in a variable. You can find out more about variable assigment here

  • Concatenation – joining the contents of variables to other variables and/or strings in output. You can find out more about concantenation here

Help! My Code Doesn’t Work!

Make sure that you check for the following things:

  • you have put the brackets after the input command
  • you have typed the variable name exactly the same (including caps), every time
  • There is a variable on the left of each assignment
  • You have used a single = for assignment
  • You have used the + symbol to concatenate (join).