Python programs become interactive by taking input from users and displaying output on the screen. This practice set covers the input() and print() functions, type conversion, and formatted output through beginner-friendly Python Input and Output Practice Questions with solutions.
1. Python Program to Accept and Display User Name
Difficulty: Foundation
Problem Statement
Write a Python program to accept the user’s name and display a welcome message.
Expected Output
Enter your name: Alex
Welcome, Alex!
Python Solution
name = input("Enter your name: ")
print("Welcome,", name + "!")
Explanation
The input() function accepts user input as a string. The print() function displays the output.
Concepts Covered
- input()
- print()
2. Python Program to Accept Two Numbers and Display Their Sum
Difficulty: Foundation
Problem Statement
Write a Python program to accept two numbers from the user and display their sum.
Expected Output
Enter first number: 15
Enter second number: 20
Sum: 35
Python Solution
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print("Sum:", num1 + num2)
Explanation
The input() function returns a string, so int() is used to convert it into an integer.
Concepts Covered
- input()
- int()
- Addition
3. Python Program to Accept Integer, Float, and String Input
Difficulty: Foundation
Problem Statement
Write a Python program to accept a student’s name, age, and percentage from the user and display them.
Expected Output
Enter name: Emma
Enter age: 20
Enter percentage: 89.5
Student Name: Emma
Age: 20
Percentage: 89.5
Python Solution
name = input("Enter name: ")
age = int(input("Enter age: "))
percentage = float(input("Enter percentage: "))
print("\nStudent Name:", name)
print("Age:", age)
print("Percentage:", percentage)
Explanation
Use int() for whole numbers and float() for decimal values.
Concepts Covered
- String Input
- Integer Input
- Float Input
4. Python Program to Calculate the Area of a Rectangle
Difficulty: Foundation
Problem Statement
Write a Python program to accept the length and width of a rectangle and calculate its area.
Expected Output
Enter length: 8
Enter width: 5
Area: 40
Python Solution
length = float(input("Enter length: "))
width = float(input("Enter width: "))
area = length * width
print("Area:", area)
Explanation
The program accepts two values and calculates the area using the formula:
Area = Length × Width
Concepts Covered
- User Input
- Variables
- Arithmetic Operator
5. Python Program to Calculate Simple Interest
Difficulty: Practice
Problem Statement
Accept principal, rate, and time from the user and calculate simple interest.
Expected Output
Enter Principal: 10000
Enter Rate: 8
Enter Time: 2
Simple Interest: 1600.0
Python Solution
principal = float(input("Enter Principal: "))
rate = float(input("Enter Rate: "))
time = float(input("Enter Time: "))
si = (principal * rate * time) / 100
print("Simple Interest:", si)
Explanation
The formula used is:
Simple Interest = (Principal × Rate × Time) / 100
Concepts Covered
- User Input
- Formula
- Arithmetic Operators
6. Python Program to Calculate the Average of Three Numbers
Difficulty: Practice
Problem Statement
Write a Python program to accept three numbers and calculate their average.
Expected Output
Enter first number: 10
Enter second number: 20
Enter third number: 30
Average: 20.0
Python Solution
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))
average = (num1 + num2 + num3) / 3
print("Average:", average)
Explanation
The average is calculated by dividing the total sum by the number of values.
Concepts Covered
- User Input
- Arithmetic Operators
7. Python Program to Display User Information
Difficulty: Practice
Problem Statement
Accept the following details from the user and display them in a formatted output.
- Name
- Age
- City
Expected Output
Enter Name: Alex
Enter Age: 22
Enter City: Delhi
------ User Information ------
Name : Alex
Age : 22
City : Delhi
Python Solution
name = input("Enter Name: ")
age = int(input("Enter Age: "))
city = input("Enter City: ")
print("\n------ User Information ------")
print("Name :", name)
print("Age :", age)
print("City :", city)
Explanation
The print() function can be used to create clean and readable console output.
Concepts Covered
- Input
- Output Formatting
8. Python Program to Convert Temperature from Celsius to Fahrenheit
Difficulty: Challenge
Problem Statement
Write a Python program to accept temperature in Celsius and convert it into Fahrenheit.
Formula:
Fahrenheit = (Celsius × 9 / 5) + 32
Expected Output
Enter Celsius: 25
Fahrenheit: 77.0
Python Solution
celsius = float(input("Enter Celsius: "))
fahrenheit = (celsius * 9 / 5) + 32
print("Fahrenheit:", fahrenheit)
Explanation
The formula converts Celsius temperature into Fahrenheit.
Concepts Covered
- User Input
- Formula
- Arithmetic Operators
9. Python Program to Calculate Total Marks and Percentage
Difficulty: Challenge
Problem Statement
Accept marks of five subjects from the user. Calculate the total marks and percentage.
Python Solution
sub1 = float(input("Subject 1: "))
sub2 = float(input("Subject 2: "))
sub3 = float(input("Subject 3: "))
sub4 = float(input("Subject 4: "))
sub5 = float(input("Subject 5: "))
total = sub1 + sub2 + sub3 + sub4 + sub5
percentage = total / 5
print("Total Marks:", total)
print("Percentage:", percentage)
Sample Output
Total Marks: 425.0
Percentage: 85.0
Explanation
The program accepts five subject marks and calculates both the total and average percentage.
Concepts Covered
- Multiple Inputs
- Variables
- Arithmetic Operators
10. Python Program to Create a Student Registration Form
Difficulty: Challenge
Problem Statement
Write a Python program to accept the following details and display them in a formatted registration form.
- Name
- Age
- Course
Python Solution
name = input("Enter Name: ")
age = int(input("Enter Age: "))
course = input("Enter Course: ")
email = input("Enter Email: ")
print("\n===== Student Registration =====")
print("Name :", name)
print("Age :", age)
print("Course :", course)
print("Email :", email)
Sample Output
===== Student Registration =====
Name : Alex
Age : 20
Course : Python Programming
Email : alex@example.com
Explanation
This program combines multiple user inputs and displays them in a structured format.
Concepts Covered
- Multiple User Inputs
- Output Formatting
- Variables
Chapter Summary
After completing this chapter, you have learned:
input()functionprint()functionint()andfloat()conversion- Accepting multiple user inputs
- Formatted console output
- Real-world input-based Python programs
Written by Shubhranshu Shekhar, who has trained 20000+ students in coding.
