-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
Introduction to Python
Python Basics
Python Syntax
Python Comments
Python Variables
Python Data Types
Python Casting
Python I/O
Python Operators
Cotrol Structures
Data Structures
Python Strings
Python Lists
Python Tuples
Python Dictionaries
Python Sets
Python Arrays
Python Bytes and Bytearray
Date and Time
Functions and Module
File Handling
Python OOP
Advanced Concepts
Python Scope
Python Modules
Python JSON
Python RegEx
Python PIP
Python Try...Except
Python String Formatting
Python User Input
Python VirtualEnv
Python Math
Python DSA
Python DSA
Lists and Arrays
Python Stacks
Python Queues
Linked Lists
Python Hash Tables
Python Trees
Python Binary Trees
Binary Search Trees
Python AVL Trees
Python Graphs
Searching Algorithms
Sorting Algorithms
In Python, you can take input from users using the built-in input()
function. It lets your program interact with users during runtime.
Use input()
to ask the user to type something:
name = input("Enter your name: ")
print("Hello", name)
✅ The input from the user is always returned as a string.
Since input()
returns a string, you’ll often need to convert it to int or float:
age = input("Enter your age: ")
age = int(age)
print("You will be", age + 1, "next year.")
price = float(input("Enter the price: "))
print("Total price after tax:", price * 1.18)
x = int(input("Enter first number: "))
y = int(input("Enter second number: "))
print("Sum is:", x + y)
Always validate the input if needed:
data = input("Enter a number: ")
if data.isdigit():
print("It's a number!")
else:
print("Invalid input")
For multiple lines, you can loop:
print("Enter lines (type 'end' to finish):")
lines = []
while True:
line = input()
if line.lower() == "end":
break
lines.append(line)
Q1. Write a Python program to ask the user to enter their first and last name, then print the full name.
Q2. Write a Python program to take input of two numbers and print their product.
Q3. Write a Python program to ask for temperature in Celsius and convert it to Fahrenheit.
Q4. Write a Python program to ask the user for their favorite color and display it in a sentence.
Q5. Write a Python program to input a number and check if it is even or odd.
Q6. Write a Python program to ask the user to enter their age, convert it to an integer, and check if they are 18 or older.
Q7. Write a Python program to take 3 float inputs and print their average.
Q8. Write a Python program to input a name and print its length using len()
.
Q9. Write a Python program to read two numbers from the user and print the larger one.
Q10. Write a Python program to input a string and print it in uppercase.
Introduction to Python
Python Basics
Python Syntax
Python Comments
Python Variables
Python Data Types
Python Casting
Python I/O
Python Operators
Cotrol Structures
Data Structures
Python Strings
Python Lists
Python Tuples
Python Dictionaries
Python Sets
Python Arrays
Python Bytes and Bytearray
Date and Time
Functions and Module
File Handling
Python OOP
Advanced Concepts
Python Scope
Python Modules
Python JSON
Python RegEx
Python PIP
Python Try...Except
Python String Formatting
Python User Input
Python VirtualEnv
Python Math
Python DSA
Python DSA
Lists and Arrays
Python Stacks
Python Queues
Linked Lists
Python Hash Tables
Python Trees
Python Binary Trees
Binary Search Trees
Python AVL Trees
Python Graphs
Searching Algorithms
Sorting Algorithms