⌨️ Python Input Function for Beginners
📚 Table of Contents
- What is input() Function?
- Taking User Input
- Input with Variables
- Converting Input Data
- Multiple Inputs
- Common Mistakes
- Practice Examples
- FAQ
💡 Quick Tip
Always convert user input into the required data type using int(), float(), etc.
⚠️ Common Mistakes
- Forgetting type conversion.
- Using wrong variable names.
- Not checking user input.
✍️ By Roshni Code Charm
📅 July 2026 | ⏱️ 5 min read
⌨️ What is input() Function?
The input() function is used to take information from the user while a Python program is running.
Basic Input Example
name = input("Enter your name: ")
print(name)
📦 Input with Variables
The value entered by the user is stored inside a variable.
age = input("Enter your age: ")
print(age)
🔄 Converting Input Data
By default, input() stores data as a string.
We use int() and float() to convert values.
age = int(input("Enter age: "))
marks = float(input("Enter marks: "))
➕ Multiple Inputs
a,b = input("Enter two numbers: ").split()
print(a)
print(b)
🚀 Real Life Example
name = input("Enter your name: ")
city = input("Enter your city: ")
print(name, city)
⭐ Why Learn input()?
- Creates interactive programs
- Allows users to enter data
- Useful for real-world applications
- Important for beginner projects
📝 Practice Examples
- Create a program to take your name and print a greeting.
- Take two numbers from the user and add them.
- Take marks and calculate percentage.
❓ Frequently Asked Questions
1. What does input() do in Python?
input() takes data from the user.
2. What data type does input() return?
input() always returns a string value.
3. How to take integer input?
Use int(input()) to take integer values.