-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassignment9.py
More file actions
101 lines (68 loc) · 2.16 KB
/
Copy pathassignment9.py
File metadata and controls
101 lines (68 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# QUESTION 1
class Circle():
def __init__(self, radius):
self.radius = radius
def getArea(self):
return 3.14*self.radius**2
def getCircumference(self):
return 2*3.14*self.radius
o = Circle(int(input('Enter radius: ')))
print(o.getArea())
print(o.getCircumference())
# QUESTION 2
class Student():
def __init__(self, name, roll):
self.name = name
self.roll = roll
def Display(self):
print('Name: '+self.name)
print('Roll No: '+self.roll)
s1 = Student('Peter', 15)
s1.Display()
# QUESTION 3
class Temperature():
def convertCelsius(self, temp):
return (5/9) * (temp-32)
def convertFarenheit(self, temp):
return (temp*(9/5)) + 32
t = Temperature()
print('Temperature in Farenheit: ', t.convertFarenheit(float(input('Enter temperature in Celcius: '))))
print('Temperature in Celcius: ', t.convertCelsius(float(input('Enter temperature in Farenheit: '))))
# QUESTION 4
class MovieDetails():
def __init__(self, mName, aName, year, rating):
self.mName = mName
self.aName = aName
self.year = year
self.rating = rating
def display(self):
print('Movie Name: '+self.mName)
print('Artist Name: '+self.aName)
print('Year of Release: '+self.year)
print('Rating: ', self.rating)
def update(self):
self.mName = input('Movie Name: ')
self.aName = input('Artist Name: ')
self.year = input('Year of Release: ')
self.rating = input('Rating: ')
print('Updated!')
m = MovieDetails('Avengers: Infinty War', 'Alan Silvestri', 2018, 8.8)
m.display()
m.update()
# QUESTION 5
class Expenditure():
def __init__(self, exp, saving):
self.exp = exp
self.saving = saving
self.sal = 0
def display(self):
print('Expenditure: ', self.exp)
print('Savings: ', self.saving)
def calculate(self):
self.sal = self.exp + self.saving
def dispSal(self):
print('Salary: ', self.sal)
obj = Expenditure(int(input('Enter expenditures: ')), int(input('Enter savings: ')))
obj.display()
obj.calculate()
obj.dispSal()