This file contains 10 beginner-friendly problems with questions, algorithms, and Python solutions.
Set 1 Questions:
- Write an algorithm to add three numbers.
- Write an algorithm to add 2 numbers and subtract from the 3rd number.
- Write an algorithm to add 2 numbers where a = 10 and b = 20.
- Write an algorithm to evaluate the following expressions:
- 10 + 20 - 30 + 5
- $5 + 10 Rs
- Evaluate
{a+b-10}/xwhere a=10, x=2, b is given by the user. - A man takes salary & saves some amount of it and spends double the savings. How much did he spend? (derive formula and implement)
- Harish works for 30 days & earns salary. He pays 30% as tax. How much tax does he pay?
- Harish has a worker; he pays 1/4 of the tax as salary. How much does he pay? (extension of previous question)
- Harish removes the worker and saves money previously given to worker & half of tax. What is total savings?
- Mythili rents a brush for 4 days and does not use it for 3 days. When not used, the website charges 30% of daily usage. Calculate total weekly charges.
Question: Write an algorithm to add three numbers.
Algorithm:
- Take three numbers as input from the user.
- Add the three numbers.
- Print the result.
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
sum_total = a + b + c
print("Sum of three numbers:", sum_total)Question: Write an algorithm to add 2 numbers and subtract from the 3rd number.
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
result = c - (a + b)
print("Result:", result)Question: Write an algorithm to add 2 numbers where a = 10 and b = 20.
a = 10
b = 20
sum_ab = a + b
print("Sum of a and b:", sum_ab)Question: Write an algorithm to evaluate:
- 10 + 20 - 30 + 5
- $5 + 10 Rs
# Expression 1
expr1 = 10 + 20 - 30 + 5
print("10 + 20 - 30 + 5 =", expr1)
# Expression 2: $5 + 10 Rs (convert USD to INR first)
usd_to_inr = 82
amount_usd = 5
amount_rs = 10
amount_usd_in_rs = amount_usd * usd_to_inr
total_amount = amount_usd_in_rs + amount_rs
print("5 USD + 10 Rs =", total_amount, "Rs")Question: {a+b-10}/x where a=10, x=2, b is given by user
a = 10
x = 2
b = int(input("Enter value for b: "))
result = (a + b - 10) / x
print("Result of (a+b-10)/x:", result)Question: A man takes salary & saves some amount. Spending = 2 × savings. Find spending.
salary = float(input("Enter salary: "))
savings = float(input("Enter savings: "))
spending = 2 * savings
print("Amount spent:", spending)Question: Harish pays 30% tax on salary.
salary = float(input("Enter salary: "))
tax = (30 / 100) * salary
print("Tax to pay:", tax)Question: Worker salary = 1/4 of tax.
tax = float(input("Enter tax amount: "))
worker_salary = tax / 4
print("Worker salary:", worker_salary)Question: Savings = previous worker salary + half of tax.
worker_salary = float(input("Enter previous worker salary: "))
tax = float(input("Enter previous tax: "))
tax_savings = tax / 2
total_savings = worker_salary + tax_savings
print("Total savings:", total_savings)Question: Mythili rents a brush 4 days, not used 3 days. Not-used charge = 30% of daily usage.
daily_rent = float(input("Enter daily rent: "))
used_days = 4
not_used_days = 3
total_amount = (daily_rent * used_days) + (daily_rent * 0.3 * not_used_days)
print("Total amount to pay for the week:", total_amount)This file contains 9 practical problems with questions, algorithms, formulas, and Python implementations, focusing on real-life applications and beginner-friendly logic.
Set 2 Questions:
- Nikhil, a movie fan, contributes to a rating system where votes are counted in multiples of 1,000. Represent votes as '1K', '1.5K', etc.
- Preeti buys oil from Russia at $50/10 liters. Calculate cost in INR. Part B: Russia gives $2 discount/10 liters. Calculate discount for 1 barrel (158.987 liters).
- Neha wants to play 170 minutes. Display in
xh : ymformat. - Manya fills first name, last name, age, percentage. Display first name, last name, full name.
- Take salary as input. If >50,000 → "middle class", else "lower middle class".
- Take salary as input. If >50,000 → "upper middle class", else add 7% increment.
- Input character 'm' for male, 'f' for female (case-insensitive).
- Menu-driven addition: choice = 1 → add two numbers, else wrong choice.
- Salary >50,000 → Deduct 10% tax. If remaining salary >50,000 → Deduct 2% more.
Question:
Nikhil, a movie fan, contributes to a rating system where votes are counted in multiples of 1,000. To make displayed ratings easier, represent every 1,000 votes as '1K'. For example, 1,500 votes → '1.5K'.
Algorithm:
- Take the number of votes as input.
- Check if votes > 0.
- Divide votes by 1000 →
votes_in_k. - Display as formatted string with
K.
votes = int(input("Enter number of votes: "))
if votes > 0:
votes_in_k = votes / 1000
print(f"Votes Display: {votes_in_k}K")
else:
print("No votes yet")Example Output:
Enter number of votes: 1500
Votes Display: 1.5K
Question Part A:
Preeti buys oil from Russia at $50 for 10 liters. How much does she pay in INR?
Question Part B:
Russia gives $2 discount per 10 liters. How much discount for 1 barrel (1 barrel = 158.987 liters)?
Algorithm Part A:
- Take liters needed.
- Calculate cost in USD:
(liters / 10) * 50. - Convert USD to INR:
USD * 82. - Print total amount.
# Part A
liters_needed = float(input("Enter liters to buy: "))
price_per_10_liters_usd = 50
usd_to_inr = 82
total_usd = (liters_needed / 10) * price_per_10_liters_usd
total_inr = total_usd * usd_to_inr
print("Total price to pay (INR):", total_inr)Algorithm Part B:
- Barrel liters = 158.987
- Discount per 10 liters = $2
- Units = barrel_liters / 10
- Total discount = units * 2 USD → convert to INR
barrel_liters = 158.987
discount_per_10_liters_usd = 2
usd_to_inr = 82
units = barrel_liters / 10
total_discount_usd = units * discount_per_10_liters_usd
total_discount_inr = total_discount_usd * usd_to_inr
print("Discount for 1 barrel (INR):", total_discount_inr)Question:
Neha has 170 minutes to play. Show it in xh : ym format.
Algorithm:
- Hours = minutes // 60
- Remaining minutes = minutes % 60
- Print formatted string
total_minutes = int(input("Enter total minutes: "))
hours = total_minutes // 60
minutes = total_minutes % 60
print(f"{hours}h : {minutes}m")Example Output:
Enter total minutes: 170
2h : 50m
Question:
Manya fills first name, last name, age, percentage. Display first name, last name, and full name.
Algorithm:
- Take first name, last name, age, percentage
- Concatenate first and last name → full name
- Print all
first_name = input("Enter first name: ")
last_name = input("Enter last name: ")
age = int(input("Enter age: "))
percentage = float(input("Enter percentage: "))
full_name = first_name + " " + last_name
print("First Name:", first_name)
print("Last Name:", last_name)
print("Full Name:", full_name)Question:
If salary > 50,000 → "middle class", else "lower middle class".
salary = float(input("Enter salary: "))
if salary > 50000:
print("Middle class")
else:
print("Lower middle class")Question:
If salary > 50,000 → upper middle class. Else, add 7% and show new salary.
salary = float(input("Enter salary: "))
if salary > 50000:
print("Upper middle class")
else:
salary = salary + (salary * 0.07)
print("Updated Salary with 7% increment:", salary)Question:
Input 'm' for male, 'f' for female, case-insensitive.
gender = input("Enter gender (m/f): ")
if gender.lower() == 'm':
print("Male")
elif gender.lower() == 'f':
print("Female")
else:
print("Invalid input")Question:
Choice = 1 → add two numbers, else wrong choice.
choice = int(input("Enter your choice (1 to add): "))
if choice == 1:
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print("Sum =", num1 + num2)
else:
print("Wrong choice")Question:
If salary > 50,000 → Deduct 10% tax. If remaining salary > 50,000 → Deduct 2% more.
salary = float(input("Enter salary: "))
if salary > 50000:
salary -= salary * 0.10 # Deduct 10%
if salary > 50000:
salary -= salary * 0.02 # Deduct 2% more
print("Final Salary after tax:", salary)- Always break problems into steps (algorithm) before coding.
- Use variables clearly for each part of calculation.
- Test with different inputs to ensure correctness.
- These problems cover basic arithmetic, percentage, loops, and user input, which strengthens your core Python fundamentals.