0% found this document useful (0 votes)
7 views

oops index(advanced)

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

oops index(advanced)

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

INDEX

S. No Program Name Date Page No Remarks

1 Write a Python program to find the gross salary of the employee. (read 09.05.22 1
Basic, Da,Hra and pf is 10% of the basic)

2 Write a Python program to convert temperature from Fahrenheit to Celsius 09.05.22 2


and vice versa (c=(fh-32)/1.8 and f=(c*1.8)+32

3 Write a Python program to find area and perimeter of a circle. (area=∏r2 09.05.22 3
perimeter=2∏r)

4 Write a Python Program to find least number must be added to x to obtain a 09.05.22 4
number exactly divisible by y.

5 Write a Python Program to find least number must be subtracted from x to 09.05.22 5
get the number exactly divisible by y.

6 Write a Python program to calculate area and perimeter of a right angled 09.05.22 6
triangle.(Base and Height are inputs)

7 On dividing x by a certain number, the quotient is y and the remainder is z. 09.05.22 7


Write a Python program to find the number.

8 Find the sum of natural numbers 1 to n.(read n as input) 09.05.22 8

9 Write a Python program to calculate Simple interest (SI=PTR/100) 09.05.22 9

10 Write a Python program to calculate area and perimeter of a rectangle. 09.05.22 10

11 Write a Python program to convert centimeters to meters and meters to 09.05.22 11


kilometers. (1 meter=100 centimeters 1 kilometer=1000 meters)

12 Write a Python program to convert the given numbers of days into years, 09.05.22 12
months and days. (Ignoring leap year)

13 Write a Python program to calculate the angle of a triangle if two angles are 09.05.22 13
given as input

14 Write a Python program to read the consumer number and number of units 09.05.22 14
consumed and the cost per unit and print the amount to be paid. (Amt=num
of units*cost)

15 Write a Python program to find addition of two numbers using subtraction 09.05.22 15
operator. Sum=a-(-b)

16 Write a Python Program to calculate area and perimeter of a triangle given 09.05.22 16
input as three sides a,b,c. Perimeter=(a+b+c) s=(a+b+c)/2 Area=sqrt(s*(s-
a)(s-b)*(s-c))

i
S. No Program Name Date Page No Remarks

17 Write a Python program to read five Subject marks and find the average. 09.05.22 17

18 Write a Python Write a program to read the values of x, y and z and print the 09.05.22 18
results of the following expressions in one line. 1. (x+y+z) / (x-y-z) 2.
(x+y+z) / 3 3. (x+y) * (x-y) * (y-z)

19 Write a Python program to Calculate Compound interest CI=p(1+r/100)n 09.05.22 19


(Inputs are p=principle amount ,r=interest rate, n=no. of years)

20 The displacement of a body (s) against time (t) where (u) is the initial velocity 09.05.22 20
and (a) is the acceleration is given by the formula S = ut + ½ at2 . Write a
Python code to find S for given u , t , a.

21 Ask the user to enter their name and then display their name three times 01.06.22 21

22 Alter the above program so that it will ask the user to enter their name and a 01.06.22 22
number and then display their name that number of times.

23 Ask the user to enter their name and display each letter in their name on a 01.06.22 23
separate line.

24 Change above program to also ask for a number. Display their name (one 01.06.22 24
letter at a time on each line) and repeat this for the number of times they
entered.

25 Ask the user to enter a number between 1 and 12 and then display the times 01.06.22 25
table for that number.

26 Ask for a number below 50 and then count down from 50 to that number, 01.06.22 26
making sure you show the number they entered in the output.

27 Ask the user to enter their name and a number. If the number is less than 10, 01.06.22 27
then display their name that number of times; otherwise display the message
“Too high” three times.

28 Set a variable called total to 0. Ask the user to enter five numbers and after 01.06.22 28
each input ask them if they want that number included. If they do, then add
the number to the total. If they do not want it included, don’t add it to the
total. After they have entered all five numbers, display the total.

29 Ask which direction the user wants to count (up or down). If they select up, 01.06.22 29
then ask them for the top number and then count from 1 to that number. If
they select down, ask them to enter a number below 20 and then count down
from 20 to that number. If they entered something other than up or down,
display the message “I don’t understand”.

ii
S. No Program Name Date Page No Remarks

30 Ask how many people the user wants to invite to a party. If they enter a 01.06.22 30
number below 10, ask for the names and after each name display “[name] has
been invited”. If they enter a number which is 10 or higher, display the
message “Too many people”

31 Set the total to 0 to start with. While the total is 50 or less, ask the user to 01.06.22 31
input a number. Add that number to the total and print the message “The
total is… [total]”. Stop the loop when the total is over 50.

32 Ask the user to enter a number. Keep asking until they enter a value over 5 01.06.22 32
and then display the message “The last number you entered was a [number]”
and stop the program.

33 Ask the user to enter a number and then enter another number. Add these two 01.06.22 33
numbers together and then ask if they want to add another number. If they
enter “y", ask them to enter another number and keep adding numbers until
they do not answer “y”. Once the loop has stopped, display the total

34 Create a variable called compnum and set the value to 50. Ask the user to 01.06.22 34
enter a number. While their guess is not the same as the compnum value, tell
them if their guess is too low or too high and ask them to have another
guess. If they enter the same value as compnum, display the message “Well
done, you took [count] attempts”.

35 Ask the user to enter a number between 10 and 20. If they enter a value under 01.06.22 35
10, display the message “Too low” and ask them to try again. If they enter a
value above 20, display the message “Too high” and ask them to try again.
Keep repeating this until they enter a value that is between 10 and 20 and then
display the message “Thank you”

36 Using the song “10 green bottles”, display the lines “There are [num] green 01.06.22 36
bottles hanging on the wall, [num] green bottles hanging on the wall, and if 1
green bottle should accidentally fall”. Then ask the question “how many
green bottles will be hanging on the wall?” If the user answers correctly,
display the message “There will be [num] green bottles hanging on the wall”.
If they answer incorrectly, display the message “No, try again” until they get
it right. When the number of green bottles gets down to 0, display the
message “There are no more green bottles hanging on the wall”.

37 WAP to grade a student with percentage of 3 subject marks : a) >=75% - A b) 01.06.22 39


>=60% or <75% - B c) >=40% or <60% - C d) <40% - F

iii
S. No Program Name Date Page No Remarks

38 WAP to identify a) Armstrong number b) palindrome for given number. 01.06.22 40

39 WAP to generate prime numbers within the given range. 01.06.22 41

40 WAP to generate Fibonacci series up to given n value. 01.06.22 42

41 WAP to demonstrate break, continue and pass statements. Write 01.06.22 43

42 a Python program to sum all the items in a list. 08.06.22 44

43 Write a Python program to get the largest number from a list. 08.06.22 45

44 Write a Python program to check whether an element exists within a tuple. 08.06.22 46

45 Write a Python program to find the key of the maximum value in a 08.06.22 47
dictionary. Sample Output: Original dictionary elements: {'Theodore': 19,
'Roxanne': 22, 'Mathew': 21, 'Betty': 20} Finds the key of the maximum and
minimum value of the said dictionary: ('Roxanne', 'Theodore')

46 Write a Python program to extract a list of values from a given list of 08.06.22 48
dictionaries. Original Dictionary: [{'Math': 90, 'Science': 92}, {'Math': 89,
'Science': 94}, {'Math': 92, 'Science': 88}] Extract a list of values from said
list of dictionaries where subject = Science [92, 94, 88] Original Dictionary:
[{'Math': 90, 'Science': 92}, {'Math': 89, 'Science': 94}, {'Math': 92, 'Science':
88}] Extract a list of values from said list of dictionaries where subject = Math
[90, 89, 92]

47 Write a program to determine whether the character entered is a vowel or not. 08.06.22 49

48 Write a program to find the greatest number from three numbers


08.06.22 50
49 Write a program that prompts the user to enter a number between 1-7 and
then displays the corresponding day of the week. 08.06.22 51

50 Write a program to calculate tax given the following conditions a. If income


is less than1,50,000 then no tax b. If taxable income is 1,50,001-3,00,000 08.06.22 52
then charge 10% tax c. If taxable income is 3,00,001-5,00,000 then charge
20% tax d. If taxable income is above 5,00,001 then charge 30% tax

51 Write a program to calculate the roots of a quadratic equation.


08.06.22 53
52 Write a program to read the numbers until -1 is encountered. Find the
average of positive numbers and negative numbers entered by the user. 08.06.22 54

iv
S. No Program Name Date Page No Remarks

53 Write a program to calculate the sum of numbers from m to n 08.06.22 55

54 Write a program to read a character until * is encountered. Also count the 08.06.22 56
number of uppercase, lowercase, and numbers entered by the users

55 Write a program using a while loop to read the numbers until -1 is 08.06.22 57
encountered. Also, count the number of prime numbers and composite
numbers entered by the user.

56 Write a Program to sum the series 1+1/2+….+1/n 08.06.22 59

57 Write a python function to check whether three given numbers can form the 15.06.22 60
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.

58 FoodCorner home delivers vegetarian and non-vegetarian combos to its 15.06.22 61


customer based on order. A vegetarian combo costs Rs.120 per plate and a
non-vegetarian combo costs Rs.150 per plate. Their non-veg combo is really
famous that they get more orders for their non-vegetarian combo than the
vegetarian combo. Apart from the cost per plate of food, customers are also
charged for home delivery based on the distance in kms from the restaurant to
the delivery point. The delivery charges are as mentioned below:

Distance in kms Delivery charge in Rs per km


For first 3kms 0

For next 3kms 3

For the remaining 6

Given the type of food, quantity (no. of plates) and the distance in kms from
the restaurant to the delivery point, write a python program to calculate the
final bill amount to be paid by a customer. The below information must be
used to check the validity of the data provided by the customer: Type of food
must be ‘V’ for vegetarian and ‘N’ for non-vegetarian. Distance in kms must
be greater than 0. Quantity ordered should be minimum 1. If any of the input
is invalid, the bill amount should be considered as -1.

v
S. No Program Name Date Page No Remarks

59 The Metro Bank provides various types of loans such as car loans, business 15.06.22 64
loans and house loans to its account holders. Write a python program to
implement the following requirements:
• Initialize the following variables with appropriate input
values:account_number, account_balance, salary, loan_type,
loan_amount_expected and customer_emi_expected.
• The account number should be of 4 digits and its first digit should be 1.
• The customer should have a minimum balance of Rupees 1 Lakh in the
account.
• If the above rules are valid, determine the eligible loan amount and the
EMI that the bank can provide to its customers based on their salary and the
loan type they expect to avail.
• The bank would provide the loan, only if the loan amount and the number
of EMI’s requested by the customer is less than or equal to the loan amount
and the number of EMI’s decided by the bank respectively. Display
appropriate error messages for all invalid data. If all the business rules are
satisfied ,then display account number, eligible and requested loan amount
and EMI’s. Test your code by providing different values for the input
variables.
Salary Loan type Eligible loan No. of EMI’s
amount required to
repay
> 25000 Car 500000 36

> 50000 House 6000000 60

> 75000 Business 7500000 84

60 Write a python program to solve a classic ancient Chinese puzzle. We count 15.06.22 68
35 heads and 94 legs among the chickens and rabbits in a farm. How many
rabbits and how many chickens do we have?
Sample Input Expected Output
heads-150 legs-400 100 50

heads-3 legs-11 No solution

heads-3 legs-12 03

heads-5 legs-10 50

vi
S. No Program Name Date Page No Remarks

61 Write a python program which finds the maximum number from num1 to 15.06.22 69
num2 (num2 inclusive) based on the following rules. a. Always num1 should
be less than num2 b. Consider each number from num1 to num2 (num2
inclusive). Populate the number into a list, if the below conditions are
satisfied a. Sum of the digits of the number is a multiple of 3 b. Number has
only two digits c. Number is a multiple of 5 c. Display the maximum element
from the list In case of any invalid data or if the list is empty, display -1.

62 The flight ticket rates for a round-trip (Mumbai->Dubai) were as follows: 15.06.22 71
Rate per Adult: Rs. 37550.0 Rate per Child: 1/3rd of the rate per adult
Service Tax: 7% of the ticket amount (including all passengers) As it was a
holiday season, the airline also offered 10% discount on the final ticket cost
(after inclusion of the service tax). Find and display the total ticket cost for a
group which had adults and children. Test the program with different input
values for number of adults and children.
Number of adults Number of children Expected Output
5 2 Total Ticket Cost:
204910.35

3 1 Total Ticket Cost:


120535.5
63 Given a list of integer values. Write a python program to check whether it 15.06.22 72
contains same number in adjacent position. Display the count of such
adjacent occurrences
Sample Input Expected Output
[1,1,5,100,-20,-20,6,0,0] 3

[10,20,30,40,30,20] 0

[1,2,2,3,4,4,4,10] 3

Write a Python program to generate the next 15 leap years starting from a
64 given year. Populate the leap years into a list and display the list 15.06.22 74

ARS Gems Store sells different varieties of gems to its customers. Write a
65 Python program to calculate the bill amount to be paid by a customer based 15.06.22 75
on the list of gems and quantity purchased. Any purchase with a total bill
amount above Rs.30000 is entitled for 5% discount. If any gem required by
the customer is not available in the store, then consider total bill amount to
be -1. Assume that quantity required by the customer for any gem will
always be greater than 0. Perform case-sensitive comparison wherever
applicable

vii
66 Write a python function, create_largest_number(), which accepts a list of 15.06.22 75
numbers and returns the largest number possible by concatenating the list of
numbers. Note: Assume that all the numbers are two digit numbers.
Sample Input Expected Output
23 34 55 55 34 23

67 WAP to find sum of series 1/1! + 4/2! + 27/3! + … using functions. 29.06.22 76

68 WAP to display powers of 2 using Anonymous function or lambda function. 29.06.22 77

69 Write a Python program to find factorial of a given number using recursive 29.06.22 78
lambda function.

70 WAP to illustrate command line arguments and function redefinition 29.06.22 79

71 WAP that has a class Person storing name and date of birth of a person. The 29.06.22 80
program should subtract the DOB from today’s date to find out whether a
person is eligible to vote or not.

72 WAP that has a class Student that stores roll, name and marks(3 subjects) of 29.06.22 82
the students. Display the information of the student with his/her percentage.

Write a program that accepts the lengths of three sides of a triangle as inputs.
73 The program output should indicate whether or not the triangle is a right 29.06.22 83
triangle (Recall from the Pythagorean Theorem that in a right triangle, the
square of one side equals the sum of the squares of the other two sides).

74 Write a python program to define a module to find Fibonacci Numbers and 29.06.22 84
import the module to another program.

75 Write a python program to define a module and import a specific function in 29.06.22 85
that module to another program

viii
S. No Program Name Date Page No Remarks

76 WAP that has a class Store which keeps a record of code and price of each 06.07.22 86
product. Display a menu of all products to the user and prompt him to enter the
quantity of each item required. Generate a bill and display the total amount.

77 Define a class Employee. Display the personal and salary details of five 27.07.22 87
employees using single inheritance.

78 Define a class student with data members as roll no and name. Derive a class 27.07.22 89
Fees from student that has data member fees and functions to submit fees and
generate receipt. Derive another class result from student that displays the
Marks and grade obtained by the student.

79 Write a program that has a class student to store the details of students in a 27.07.22 91
class. Derive another class toppers from the student that stores records of only
top 3 students of the class.

80 Write a program that has a class train with data members no_of_ seats_1 st, 27.07.22 94
no_of_ seats_2Tier, no_of_ seats_3Tier and member functions to set and
display the data. Derive a class Reservation that has the data members
seats_booked_1 st ,seats_booked_2 tier and the seats_booked_3 tier and
functions to book and cancel tickets and display status.

81 Write a program that extends the class Employee .Derive a class manager from 27.07.22 96
employee so that it lists all the details of manager as well as the details of the
employees working under the manager.

82 Write a Program to demonstrate multi level inheritance 10.08.22 97

83 Program to demonstrate multi path inheritance 10.08.22 98

84 Program to illustrate the concept of abstract class. 10.08.22 99

85 Program to add two complex numbers without overloading the + operator 10.08.22 101

86 Program to overload the +operator on a complex object 10.08.22 102

87 Program to compare two objects of user defined class type 10.08.22 104

88 Program that overloads the + operator on a class student that has attributes 10.08.22 106
name and marks.

89 Program to demonstrate abstract class 10.08.22 107

90 Program to demonstrate MRO of single inheritance 10.08.22 100

91 Program to demonstrate MRO of multilevel inheritance. 10.08.22 111

92 Program to demonstrate MRO of Multiple Inheritance 10.08.22 112

93 Create a file “intro.txt” in python and ask the user to write single line of text 17.08.22 114
by user input

ix
94 Create a text file ”MyFile.txt” in python and ask the user to write 3 separate 17.08.22 115
lines with three input statements from the user.

95 Write a program to read the contents of both files created in the above programs 17.08.22 117
and merge the contents into file “merge.txt” and avoid using close() to close the
file.

96 Count number of uppercase , lowercase, digits in the file “merge.txt”. 17.08.22 119

97 Program to count the total number of lines and the total number of lines starting 17.08.22 121
with A,B,C.

98 Total occurrences of a specific word form text file “merge.txt” 17.08.22 123

99 Read n number of letters from text file “merge.txt” ,read the first line, read the 17.08.22 124
specific line from text file “merge.txt”

100 Replace all spaces from text with dash (-) 17.08.22 125

101 Write a program to know the cursor position and print the text according to 17.08.22 126
below-given specifications:
1. Print the initial position
2. Move the cursor to 4th position
3. Display next 5 characters
4. Move the cursor to the next 10 characters
5. Print the current cursor position
6. Print next 10 characters from the current cursor position

102 Write a program that reads text from a file and writes it into another file but in 17.08.22 128
the reverse order.

103 Write a program that reads a file and prints only those lines that has the word 17.08.22 129
‘print’

104 Write a program to edit a record stored in ‘employee’.txt file 17.08.22 130

105 Write a program to read a file that contains small case characters then write 17.08.22 132
these characters into another file with all lowercase characters converted into
uppercase

106 Write a menu driven program that reads details of a faculty. Provide options to 17.08.22 133
add a new record, delete a record, update any existing record, and display all are
a particular record.

107 Program to handle the divide by zero exception 17.08.22 134

108 Program with multiple except blocks. 17.08.22 135

109 Program having an exception clause handling multiple exceptions 17.08.22 136
simultaneously
110 Program to demonstrate the use of except: block 17.08.22 137

111 Write a program that opens a file and writes data to it . Handle exceptions that 17.08.22 138
can be generated during the I/O operations

x
xi

You might also like