Sona College of Technology (Autonomous), Salem -5.
( I YEAR / I SEMESTER)
U23PPR105- Problem Solving using Python Programming
ASSIGNMENT – I
Last date for submission: 22.9.25
1. Write an algorithm and flowchart that perform the following:
Ask a user to enter the number. If the number is between 0 and 9, write the word
blue. If the number is between 10 and 19, write the word red, if the number is
between 20 and 29, write the word green. If it is any other number, write that it is
not a correct color option.
[Link] wavelength of visible light ranges from 380 to 750 nanometers (nm). While the
spectrum is continuous, it is often divided into 6 colors as shown below:
Write a Python program that reads a wavelength from the user and reports its color.
Display an appropriate error message if the wavelength entered by the user is outside
of the visible spectrum.
[Link] a Pseudo code to get purchase amount as input. If it is greater than Rs.2000, give
a discount of Rs.500. Print the final amount.
Write a pseudo code to input the customer’s quantity purchased and the rate. Calculate the
total purchase price and display it along with the gift to be presented. The gifts to the
customers are given as under:
Amount of purchase (Rs.) Gift
250 and above but less than 500 A key chain
500 and above but less than A water Bottle
1000
1000 and above A handbag
4. Most years have 365 days. However, the time required for the Earth to orbit the Sun is
actually slightly more than that. As a result, an extra day, February 29, is included in some
years to correct for this difference. Such years are referred to as leap years. The rules for
determining whether or not a year is a leap year follow:
Any year that is divisible by 400 is a leap year.
Of the remaining years, any year that is divisible by 100 is not a leap year.
Of the remaining years, any year that is divisible by 4 is a leap year.
All other years are not leap years.
Write an algorithm and Pseudo code that reads a year from the user and displays a
message indicating whether or not it is a leap year.
[Link] a python program to print the following grid.
*
**
***
****
*****
6. Write a program to perform the calculations based on the condition given by the
user. For example, calculate the salary statement for an employee based on the following
conditions.
Basic pay DA HRA Special Loan
pay
< 10000 25% 15% 5% 500
>=10000<=50000 35% 20% 10% 1000
>50000 50% 30% 20% 1500
7. Write a Python Program to calculate the electricity bills as per units consumed by the
user.
Unit Charge
0-200 3
201-400 4.5
401-800 6.5
>800 Per unit 8
Add an addition charge of Rs. 100 as meter charge for all.
8. A cab driver charges Rs. 15.00 on the first meter (km). He charges an extra of Rs. 22.00
on the next 5 kms. Anything beyond that is charged at Rs. 2.50 per km. Write a Python
program to input the distance covered and calculate the cab charges.