Skip to content

Commit c0bd976

Browse files
committed
add Q3.py
1 parent ae11489 commit c0bd976

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

exercises/Q5.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'''
2+
Question 5
3+
Level 1
4+
5+
Question:
6+
Define a class which has at least two methods:
7+
getString: to get a string from console input
8+
printString: to print the string in upper case.
9+
Also please include simple test function to test the class methods.
10+
11+
Hints:
12+
Use __init__ method to construct some parameters
13+
14+
15+
'''
16+
17+
18+
class InOutString(object):
19+
def __init__(self):
20+
self.str = "No Input Given"
21+
22+
def getString(self):
23+
self.str = input("Type something")
24+
25+
def printString(self):
26+
print(self.str)
27+
28+
tst = InOutString()
29+
tst.getString()
30+
tst.printString()

0 commit comments

Comments
 (0)