- 2

Creating your Own class

Calculate area and perimeter of circle with class In this task you will be creating your own class for a circle and define two methods to compute its perimeter and area. Name the class Circleand initialize it using __init__()which takes in argument radiusalong with self and initializes its radius self.radius = radius. Define another two methods area()and perimeter()which takes only the keyword self as argument and calculates the area(3.14xradius^2) and perimeter (2*3.14xradius) respectively. Finally, instantiate an object for Circle of radius 3and save it as circle Calculate the area of circleusing its .area()method and save it as circle_area Calculate the perimeter of circleusing its .perimeter()method and save it as circle_perimeter Print out circle_areaand circle_perimeter https://code.sololearn.com/c62PbpZ7woqZ/?ref=app

26th Oct 2019, 2:56 AM
Payal Ash
Payal Ash - avatar
9 ответов
+ 3
We don't do homework here, show us what you've done first.
26th Oct 2019, 3:14 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
Payal Ash no one is going to help you without any attempts, we don't do homework in this forum, we correct code. Show us were you were stuck, and we'll give you hints, it's not about me knowing or not knowing how to solve your problem.
26th Oct 2019, 3:19 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
Payal Ash that is not how you define a class, I'm just going to give you a start and you have to continue your code, if you still don't understand how classes work, I suggest you go back to your teacher's lesson or sololearn lesson. https://code.sololearn.com/c0X44b1U66jD/?ref=app
26th Oct 2019, 3:59 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
How to attempt this in solo learn? I have my python glab book were I am doing it Jay Matthews
26th Oct 2019, 3:20 AM
Payal Ash
Payal Ash - avatar
0
Payal Ash there is Desktop version. But the code playground is still available on mobile version.
26th Oct 2019, 3:21 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
Just wanna confirm 4th step Finally, instantiate an object for circle of radius 3 and save it as circle I have used code as Circle = radius(3) Which throw an error if you can clear that part rest code is correct Aymane Boukrouh And thanks for help and comment
26th Oct 2019, 3:31 AM
Payal Ash
Payal Ash - avatar
0
Payal Ash can you please share the whole code (or at least the raius function/class)? No one is going to be able to do anything with just what you shared. It would be better to write it in code playground and share it.
26th Oct 2019, 3:34 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
I have shared the code if you can check Aymane Boukrouh
26th Oct 2019, 3:46 AM
Payal Ash
Payal Ash - avatar
- 1
I m a learner and I can't send whole links here I just wanna help Aymane Boukrouh If you can't don't comment
26th Oct 2019, 3:16 AM
Payal Ash
Payal Ash - avatar