Slip 20 A) Write a python program to create a
class Circle and Compute the Area and the circumferences of the circle.(use
parameterized constructor)
Answer :
class Circle():
def init (self, r):
self.radius = r
def area(self):
return self.radius**2*3.14
def perimeter(self):
return 2*self.radius*3.14
NewCircle = Circle()
NewCircle.init(8)
print(NewCircle.area())
print(NewCircle.perimeter())
Output :
Slip 20 B) Write a Python script to generate
and print a dictionary which contains a number (between 1 and n) in the
form(x,x*x). Sample Dictionary (n=5) Expected Output: {1:1, 2:4, 3:9, 4:16,
5:25}
Answer :
dict={}
n=5
for x in range(1,n+1):
dict[x]=x*x
print(dict)
Output :
2 comments:
We are Australia's top academic support experts, and we have assisted countless students in completing their programming assignments on time. You'll be relieved to know that the strain of completing your assignments will be lifted with our assistance. Get in touch with our team for Programming Assignment Help
Looking for high-qualitySample Assignment UK ? Explore our wide range of academic samples to enhance your understanding and excel in your studies
Post a Comment