Question: Python Code * Implement a constructor that accepts one parameter: name (type str ). This parameter should initialize the similarly named class instance variable (hint:

Python Code

* Implement a constructor that accepts one parameter: name (type str ). This parameter should initialize the similarly named class instance variable (hint: these would start with self. )

* Implement a method named sayHello. This method should accept a single argument: n (type int ). The result of this method should be printing on the standard output out n times the welcome line: Welcome to the assignment, XXXX!

Where XXXX is class instance variable storing name, supplied during the construction of the object.

* Write a method named list that accepts a single argument: n (type int ).

This method should return a list containing n items XXXX NN , where XXXX is the name supplied during the construction of the object, and NN is sequence number. For example, when running the following code

a = Assignment2("Stacey")

b = list(5)

print(b)

The output should be ['Stacey 1', 'Stacey 2', 'Stacey 3', 'Stacey 4', 'Stacey 5'] .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!