-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPy_Exercise-5.py
More file actions
30 lines (22 loc) · 755 Bytes
/
Copy pathPy_Exercise-5.py
File metadata and controls
30 lines (22 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -------------------------------------------------------------------------
# Author: Quang Tran
# Date: May 9th, 2019
# -------------------------------------------------------------------------
"""
Question:
Define a class which has at least two methods:
getString: to get a string from console input
printString: to print the string in upper case.
Also please include simple test function to test the class methods.
"""
class MyClass:
def __init__(self):
self.aString = ""
def getString(self):
self.aString = input("Please enter something: ")
return self.aString
def printString(self):
print("You have just entered: " + self.aString.upper())
myObj = MyClass()
myObj.getString()
myObj.printString()