Exercise Questions
1. A weather station records temperatures. Write a Python program that takes a
temperature value and determines if it's an even or odd number of degrees.
2. You're designing a POS system that takes the price of two items and calculates their
total, di erence, and ratio. Write a program to perform these operations.
3. A simple calculator app asks users to input two numbers and then displays the result
of all arithmetic operations: addition, subtraction, multiplication, division, floor
division, and modulus.
4. A real estate agent wants to automate the calculation of plot areas. Write a program
to calculate the area of a rectangle using user inputs for length and width.
5. A website checks if a user-entered username is a palindrome (reads the same
forward and backward). Write a program to validate this.
6. In a chat application, you need to count how many vowels appear in a given user
message. Write the code to do this.
7. A teacher stores student names in a list. Write a program to input 5 student names
and print each one using a loop.
8. A store keeps product data as key-value pairs in a dictionary. Write code to add a new
product to this inventory.
9. An ATM only allows withdrawals in multiples of 100. Write a program that checks if
the entered amount is valid. If it is, print "Transaction successful"; else, print "Invalid
amount".
10. A school learning app needs a multiplication table feature. Write a program using a
for loop that prints the table of a number entered by the user.
11. A website allows 3 login attempts. If the user enters the correct password, print
"Welcome!". Otherwise, block access after 3 failed attempts. Use a while loop.
12. Create a program that takes a number as input and checks whether it is a prime
number using a loop and conditions.
13. Create a list of 5 item prices. Calculate the total bill, apply a 10% discount, and print
the final amount.
14. You’re building a simple banking system. Create a class Bank Account with the
following features: Attributes: account number, account holder name, balance and
Methods: deposit(), withdraw(), and display_balance()
15. Design a class Student with attributes like name, roll number, and marks. Add
methods to: Display student details and Calculate and return percentage based on
marks (assume marks out of 500)