Technical Roadmap

How to take input output in python

In this section, we will learn how to take input from the user and print it as an output in Python.

Taking Input: The input() Function

In Python, we use the input() function to get data as input from the user. When you call this function, the program pauses and waits for the user to type something and press Enter. When you press Enter, your input is saved in a variable temporarily.

Python (Input)
# Taking input from the user
user_name = input("Enter your name: ")
print("Hello", user_name)
Output
Enter your name: Riya
Hello Riya
💡 The Logicoria Tip

The input() function takes every input as a String. So remember to use typecasting whenever required.

Providing Output: The print() Function

To display information on the screen, we use the print() function. You can pass strings, numbers, or variables inside the print function. The print() functions adds a new line by default.

Python (Output)
# Basic Print
print("Welcome to Logicoria!")

# Multiple Values
print("Total Articles in Logicoria: ", 100)

# Custom Separator
print("01", "01", "2026", sep="-")
Output
Welcome to Logicoria!
Total Articles in Logicoria: 100
01-01-2026
💡 The Logicoria Tip

Always provide a prompt inside the input("Enter your name here: ") function. This helps the user to input correctly so they aren't staring at a blank screen!

Advanced Output: String Formatting (f-strings)

This is the modern way to print a variable inside a string by using an f at the start of the quotes.

Python (F-Strings)
name = "Logicoria"
articles = 100

# The F-String way 
print(f"{name} has {articles} articles")
Output
Logicoria has 100 articles