Python Assignments Set
Python Assignments Set
Day -1
1. Write a code to find the minimum among three given
numbers.
2. Write a code to check whether a given number is a
palindrome.
3. Write a code to find the sum of numbers divisible by 4.The
code must allow the user to accept a number and add it to the
sum if it is divisible by 4. It should continue accepting numbers
as long as the user wants to provide an input and should
display the final sum.
4. A three digit number is said to be an “Armstrong number” if
the sum of the third power of its individual digits is equal to
the number itself.Write a program to check whether a number
is armstrong or not.
divisible scholarship%
applicable
by 7
among the two.
If there are 500 students who have joined the university, write
a code to calculate and display the final fees to be paid by
each student.
You may accept the branch of study, score and course fee as
inputs for each student and calculate the final fees to be paid
by each student based on formulae given below:
Scholarship amount=course fee * (scholarship%)
Final fee= course fee - scholarship amount
Day-2
Between 73 and 79 B
Between 65 and 72 C
Between 0 and 64 D
It should display the product of the three values except when one of the
integer value is 7. In that case, 7 should not be included in the product and
the values to its left also should not be included.
If there is only one value to be considered, display that value itself. If no
values can be included in the product, display -1.
Note: Assume that if 7 is one of the positive integer values, then it will occur
only once. Refer the sample I/O given below.
Sample Expected
Input Output
1, 5, 3 15
3, 7, 8 8
7, 4, 3 12
1, 5, 7 -1
10. You have x no. of 5 rupee coins and y no. of 1 rupee coins. You want to
purchase an item for amount z. The shopkeeper wants you to provide exact
change. You want to pay using minimum number of coins. How many 5
rupee coins and 1 rupee coins will you use? If exact change is not possible
then display -1.
2 4 21 1 4
11 2 11 1 2
3 3 19 -1
Day -3
11. Write a Python program to generate the next 15 leap years starting from
a given year. Populate the leap years into a list and display the list.
12. ARS Gems Store sells different varieties of gems to its customers.
Assume that quantity required by the customer for any gem will always be
greater than 0.
gems_list=["Emerald","Ivory","Jasper","Ruby","Garnet"]
#Price of gems available in the store. gems_list and price_list have one-to-
one correspondence
price_list=[1760,2119,1599,3920,3999]
13. Write a python function to check whether three given numbers can form
the sides of a triangle.
Hint
: Three numbers can be the sides of a triangle if none of the numbers are
greater than or equal to the sum of the other two numbers.
heads-3 legs-12 03
heads-5 legs-10 50
15. Write a python program which finds the maximum number from num1 to
num2 (num2 inclusive) based on the following rules.
16. Write a python program to generate the ticket numbers for specified
number of passengers traveling in a flight as per the details mentioned
below:
The ticket number should be generated as airline:src:dest:number
where
1. Consider AI as the value for airline
2. src and dest should be the first three characters of the source and
destination cities.
3. number should be auto-generated starting from 101
The program should return the list of ticket numbers of last five passengers.
Note: If passenger count is less than 5, return the list of all generated ticket
numbers.
Sample Input Expected Output
destination =
London
no_of_passenger
s = 10
source =
Australia
destination =
France
no_of_passenger
s=2
and use it to translate your Christmas wishes from English into Swedish.
That is, write a python function translate() that accepts the bilingual
dictionary and a list of English words (your Christmas wish) and returns a list
of equivalent Swedish words.
Day-4
18. The road transport corporation (RTC) of a city wants to know whether a
particular bus-route is running on profit or loss.
The bus runs on multiple routes having different distance in kms and
number of passengers.
Write a function to calculate and return the profit earned (Rs) in each route.
Return -1 in case of loss.
Write a python function which performs the run length encoding for a given
String and returns the run length encoded String.
AAAABBBBCCCCCCCC 4A4B8C
AABCCA 2A1B2C1A
21. Care hospital wants to know the medical speciality visited by the
maximum number of patients. Assume that the patient id of the patient
along with the medical speciality visited by the patient is stored in a list. The
details of the medical specialities are stored in a dictionary as follows:
{
"P":"Pediatrics",
"O":"Orthopedics",
"E":"ENT
}
Note:
1. Assume that there is always only one medical speciality which is
visited by maximum number of patients.
2. Perform case sensitive string comparison wherever necessary.
[101,P,102,O,302,P,305,P] Pediatrics
[101,O,102,O,302,P,305,E,401,O,656,O] Orthopedics
[101,O,102,E,302,P,305,P,401,E,656,O,987,E ENT
]