Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions