In Python, handling Input and Output (I/O) is fundamental for interacting with users. Based on the lesson structure you are managing in your Python Basics module, here is a breakdown of how these functions work.
The print() function is used to display data to the standard output device (usually your screen).
Basic Usage: You can pass strings, numbers, or variables directly.
Multiple Arguments: Use commas to print multiple items; Python automatically adds a space between them.
Formatting: You can use f-strings (formatted string literals) for a clean way to include variables inside strings.
name = "Admin" print("Hello, World!") print("User:", name) print(f"Welcome back, {name}!") # f-string method
The input() function allows you to pause program execution and wait for the user to type something.
Default Type: Crucially, input() always returns a string.
Prompt: You can pass a string to the function to display a message to the user.
user_name = input("Enter your name: ") print(f"Hello, {user_name}")
Since input() gives you a string, you must use Type Casting (the next lesson in your module) to perform math. If you don't convert the input, Python will throw an error or concatenate the strings instead of adding them.
| Scenario | Code Example |
| Integer Input | age = int(input("Enter age: ")) |
| Float Input | price = float(input("Enter price: ")) |
You can customize how the print() function behaves using these optional arguments:
sep: Changes the separator between multiple objects (default is a space).
end: Changes what is printed at the very end (default is a newline \n).
# Custom separator print("Python", "Basics", "Module", sep="-") # Output: Python-Basics-Module # Prevent moving to a new line print("Hello", end=" ") print("World") # Output: Hello World
Copyright ©2025. All Rights Reserved Emblab THE RAVE INNOVATION