File tree Expand file tree Collapse file tree 3 files changed +64
-7
lines changed Expand file tree Collapse file tree 3 files changed +64
-7
lines changed Original file line number Diff line number Diff line change @@ -105,3 +105,31 @@ def prog_2():
105
105
print (l )
106
106
print (t )
107
107
# prog_2()
108
+
109
+
110
+ # ========================= Question_5: ===========================================
111
+ # Define a class which has at least two methods:
112
+ # getString: to get a string from console input
113
+ # printString: to print the string in upper case.
114
+ # Also please include simple test function to test the class methods.
115
+ #
116
+ # Hints:
117
+ # Use __init__ method to construct some parameters
118
+
119
+ class Class_1 :
120
+ def __init__ (self , str_ ):
121
+ self .str_ = str_
122
+
123
+ def getString (self ):
124
+ print ("Enter string:" )
125
+ self .str_ = input ()
126
+ return
127
+ def printString (self ):
128
+ return print (self .str_ )
129
+
130
+ x = Class_1 ("Salom, Doston" )
131
+ x .printString ()
132
+
133
+
134
+
135
+
Original file line number Diff line number Diff line change @@ -114,3 +114,32 @@ prog_2()
114
114
```
115
115
* * *
116
116
117
+ ## Question_5: ##
118
+ ** Description:**
119
+
120
+ Define a class which has at least two methods:\
121
+ * getString: to get a string from console input
122
+ * printString: to print the string in upper case.
123
+ * Also please include simple test function to test the class methods.
124
+
125
+ ** Hints:**
126
+ Use __ init__ method to construct some parameters
127
+
128
+ ``` python
129
+ class Class_1 :
130
+ def __init__ (self , str_ ):
131
+ self .str_ = str_
132
+
133
+ def getString (self ):
134
+ print (" Enter string:" )
135
+ self .str_ = input ()
136
+ return
137
+
138
+ def printString (self ):
139
+ return print (self .str_)
140
+
141
+ x = Class_1(" Salom, Doston" )
142
+ x.printString()
143
+ ```
144
+ * * *
145
+
You can’t perform that action at this time.
0 commit comments