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.
If you have forgotten your Replit account user name or password, ask your Coder Coach.
This task contains three code examples.
Look at each example , study it carefully. Write a prediction of what it will do when it runs. Your prediction should be added to the code as comments. You should use the key terms variable, assign and concatenate in your prediction.
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()) |
Need more help with input? click here
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
Make sure that you check for the following things: