Input & Output practice ➡️
Input and Output in Python
The first step in our programming journey is input and output in Python. These are super important skills that will help you create interactive programs.
Output: Talking to the User
When we want our program to show something to the user, we use
the print()
function. It's like making your
computer speak!
print("Hello, I'm a Python program!")
Variables: Remembering Things
Variables are like boxes where we can store information. We can give them names and put different types of data inside them.
favourite_colour = "blue"
Input: Listening to the User
The input()
function lets us ask the user for
information. It's like giving the user a chance to speak to our
program!
name = input("What's your name? ")
Putting It All Together
We can use input, variables, and output together to make our programs interactive. Here's a cool example:
nickname = input("What is your nickname? ")
print(nickname, "is a great nickname!")
In this example, we ask for the user's nickname, store it in a variable, and then use that variable to print a friendly message.
Now it's your turn to try! Can you make a program that asks for someone's favourite animal and then says something nice about that animal? Press inspire me for more ideas of what to code.
Write a program to...
