Python5 min read

Python Input/Output

Get user input and display output in Python.

Emily Davis
December 18, 2025
0.0k0

Interact with users.

Print Output

```python print("Hello World") print("Welcome", "to", "Python")

Multiple lines print("""Line 1 Line 2 Line 3""") ```

Get User Input

```python name = input("What's your name? ") print(f"Hello {name}!") ```

Input with Type Conversion

```python # Input is always string age = input("Enter your age: ") age = int(age) # Convert to integer

if age >= 18: print("You're an adult!") ```

Formatted Output

```python name = "Chris" city = "Portland" age = 27

F-string print(f"I'm {name} from {city}, age {age}")

Format method print("I'm {} from {}".format(name, city)) ```

Print with Separator

```python print("apple", "banana", "cherry", sep=", ") # Output: apple, banana, cherry

Without newline print("Loading", end="...") print("Done!") # Output: Loading...Done! ```

Remember

- input() always returns string - Convert types as needed - Use f-strings for formatting

#Python#Beginner#I/O