Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON CODE PLEASE... This is a custom practice question for a test. I need help with Question P1B Part 2. Its using Initialization Function the

PYTHON CODE PLEASE... This is a custom practice question for a test. I need help with Question P1B Part 2. Its using Initialization Function the __init__ method.

'''Question P1A Write a definition line for a class called Square with a doc string included. Then:1. Define an initialization function that takes an integer parameter (sideLen) and creates that variable in the class, and a perimeter value (which is the side length times four).2. All squares have 4 sides. Create an attribute of the class called numSides and set it equal to 4.3. In the class, define a method named area that takes no parameters. This method should return the area of the square.'''

'''Question P1B Assume that the code for the class Square (Question P1A)has been saved in a file named square.py in the same folder as the code for this problem. Write code that performs the following tasks:

1. Import the module that defines the Square class

2. Use a loop to create a dictionary where the keys are the integers 1 through 10, and the corresponding values are instances of the Square class using those side lengths.

3. In either the same loop or a second one, add up the areas of the ten squares and print the result. Use the area() method for full credit.'''

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

KEY QUESTION Refer to the table in question

Answered: 1 week ago