Skip to content

Commit 06b77a6

Browse files
added SET 5 to folder
1 parent 9575475 commit 06b77a6

File tree

6 files changed

+184
-0
lines changed

6 files changed

+184
-0
lines changed

Week 3/SET 5/Questions.txt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Q1.Employee payroll system
2+
Employee name.
3+
Employee ID
4+
Basic pay
5+
HRA
6+
TA
7+
DA
8+
Grade pay
9+
Deduction 5% from Basic pay
10+
Find the Gross pay, Net pay (Grade pay + deductions) and print all the details given
11+
above, using class and object of get () method and cal( )method.
12+
13+
Q2.Student management system
14+
Student name
15+
Student id as inputs with marks for 5 Subjects, calculate and round of the subject
16+
marks to 10 and then find CGPA, Grade using object and class concept of oops 
17+
Solve the above by creating a base class and derived class use inheritance to solve it.
18+
19+
Q3. Instantiate the X class using self and then using self in the get () method and to
20+
achieve composition you can instantiate other objects in the class and then use those
21+
instances that Generate output of the total code which has both inheritance and composition.
22+
23+
Q4.An Internet service provider has three different subscription packages for its
24+
customers: Package A: for $9.95/month, 10 hours of access are provided. Additional hours
25+
are $2.00/hour. Package B: for $14.95/month, 20 hours of access are provided. Additional
26+
hours are $1.00/hour. Package C: for $19.95/month, unlimited access is provided.
27+
Write a program using objects and classes that calculates a customer’s monthly bill. 
28+
It should ask which package the customer has purchased and how many hours were
29+
used. It
30+
should then display the total amount due.
31+
Input validation: be sure the user only selects package A, B, or C.  Also, the number
32+
of
33+
hours used in a month cannot exceed 744.
34+
35+
Q5.Write a program using object-oriented concepts that calculates and displays a person’s
36+
body mass index (BMI).  The 
37+
BMI is often used to determine whether a person with sedentary lifestyle is
38+
overweight or underweight for his or her height.  A person’s BMI is calculated with
39+
the following formula:
40+
BMI = weight * 703/height^2
41+
where weight is measured in pounds and height is measured in inches.  The program
42+
should display a message indicating whether the person has optimal weight, is
43+
underweight, or is overweight.  A sedentary person’s weight is considered to be
44+
optimal if his or her BMI is between 18.5 and 25.  If the BMI is less than 18.5, the
45+
person is considered to be underweight.  If the BMI value is greater than 25, the
46+
person is considered to be overweight.
47+
48+
49+
50+

Week 3/SET 5/Task-1.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
class Employee:
2+
def __init__(self, name, age,basic,grade):
3+
self.name = name
4+
self.age = age
5+
self.basic = basic
6+
self.grade = grade
7+
8+
9+
def set(self):
10+
print("Employee Name:",self.name)
11+
print("Employee Age:",self.age)
12+
13+
def ComputeSalary(self):
14+
hra = 0.2 * self.basic
15+
da = 0.5 * self.basic
16+
pf = 0.11 * self.basic
17+
ta = 0.075 * self.basic
18+
19+
# Condition to compute the
20+
# allowance for the person
21+
if self.grade == 'A':
22+
allowance = 1700.0
23+
elif self.grade == 'B':
24+
allowance = 1500.0
25+
else:
26+
allowance = 1300.0;
27+
gross = round(self.basic+ ta + hra + da + allowance - pf)
28+
print(gross)
29+
30+
31+
emp = Employee("Sam", 36,1000,"A")
32+
emp.set()
33+
emp.ComputeSalary()

Week 3/SET 5/Task-2.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Student:
2+
def __init__(self):
3+
self.name = input("Enter your name:")
4+
self.roll = int(input("Enter your roll number:"))
5+
self.marks=list()
6+
for i in range (5):
7+
self.marks.insert(i,int(input("enter %d th mark :"%(i+1))))
8+
9+
10+
class Test(Student):
11+
def check(self):
12+
print("Your average is", sum(self.marks)/5)
13+
14+
class Admin(Test):
15+
def display(self):
16+
print("=== Student info is ===")
17+
print("Name is : ", self.name)
18+
print("Roll number is : ", self.roll)
19+
20+
obj = Admin()
21+
obj.check()
22+
obj.display()

Week 3/SET 5/Task-3.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Parent:
2+
3+
def m1(self):
4+
print('Parent Class Method called...')
5+
6+
class Child(Parent):
7+
8+
def __init__(self):
9+
print('Child Class object created...')
10+
self.ob1=Parent()
11+
print('Composite class object also created...')
12+
13+
def m2(self):
14+
print('Child Class Method called...')
15+
16+
17+
obj = Child()
18+
obj.m1()
19+
obj.m2()

Week 3/SET 5/Task-4.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
limit=0
2+
print("Which package do you have A, B, or C? : ")
3+
package =str(input())
4+
5+
if(package == 'A'or package == 'B'or package == 'C'):
6+
print("How many hours were used:")
7+
hours=int(input())
8+
if(hours > 744 or hours < 0):
9+
print("Hours cannot be greater than 744 or less than 0!! \n\n")
10+
print("Enter hours again: ")
11+
hours=int(input())
12+
13+
if(package == "A"):
14+
15+
limit = 9.95;
16+
17+
if(hours < 10):
18+
total = limit;
19+
20+
else:
21+
total = ((hours - 10) * 2) + limit
22+
23+
print("The amount due is: $%.2f"%total)
24+
25+
if(package == 'B'):
26+
27+
limit = 14.95;
28+
if(hours < 20):
29+
total = limit;
30+
else:
31+
total = ((hours - 20) * 1) + limit;
32+
33+
print("The amount due is: $%.2f"%total)
34+
35+
if(package == 'C'):
36+
37+
limit = 19.95;
38+
total = limit;
39+
print("The amount due is: $%.2f"%total)

Week 3/SET 5/Task-5.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def main():
2+
# Ask for the user's weight in pounds.
3+
weight = int(input('Please enter your weight in pounds: '))
4+
5+
# Ask for the user's height in inches.
6+
height = int(input('Please enter your height in inches: '))
7+
8+
# Calculate the BMI (BMI = weight*703/height^2)
9+
BMI = (weight * 703.0) / (height*height)
10+
print ('Your BMI is %.1f'%BMI)
11+
12+
# Determine whether the user is underweight, overweight, or optimal
13+
if BMI < 18.5:
14+
print('You are underweight.')
15+
elif BMI > 25:
16+
print('It would appear that you are overweight.')
17+
else:
18+
print('You are at an optimal weight.')
19+
20+
# Call the main function.
21+
main()

0 commit comments

Comments
 (0)