2.3: 🧺 Input

Topic

2.3: 🧺 Input

Topic Progress:

Some programs we make will need to allow the user to input something so it can process that information. This is where we want to use input commands. These allow us to take an input, store it as a variable and then do further processing with it.

To get user input, all we need to do is type is input(). In a lot of cases, we would use a variable to save this information, but for this lesson, we can print out the result directly. Remember, you can put anything that the compiler treats as text in the print brackets to make it print, for example:

print("some words")
print(x)
print(input())

‘input()’ is what we call a function. A function is just some code already written and given a name which we then want to run again. You’ve already met another function print().

Your task for this section is to write some code to print out whatever the user inputs.

Side note: You may wonder why an input function has brackets when we don’t put anything in them. The truth is we can put something in them. Try inputting a string (words in “quotation” ‘marks’) inside the input function: input(‘Like this’) and see what happens. How might this be useful?

@

Not recently active