2.2.1.4 Input and Output Operations
Python Programming
Input and output operations allow you to interact with the user. You can ask the user to enter data (input) and display information to the user (output).
- Input: Use the input () function to get user input. The input () function displays a message on the screen and waits for the user to type something and press Enter. The text entered by the user is then stored in a variable. For example:
python
name = input("Enter your name: ")This line of code asks the user to enter their name and stores it in the variable name.
- Output: Use the print () function to display information on the screen. The print () function takes one or more arguments and displays them. For example:
python