Question:

Define a class which has at least two functions(methods):

getString: to get a string from console input.

printString: to print the string in upper case.

Also please object reference to test the class methods.

Hints:

1. Use __init__ method to construct some parameters

2. Use input() function. 

3. use string upper() function.

Solution:

class InputOutString:
    def __init__(self):
        self.s = ""

    def getString(self):
        self.s = input()

    def printString(self):
        print(self.s.upper())

strObj = InputOutString()
strObj.getString()
strObj.printString()

Discussion:

1. Create a class with name

2. Used Constructor to declare the member variable

3. getString() function to get input from the user

4. printString() to print the user input in upper case format

5. Created an object reference for the class

6. Called the getString() and printString() function using the dot(.) reference