10000 Updated question 5 · uceimmp/python@1735099 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1735099

Browse files
committed
Updated question 5
1 parent 5f73c47 commit 1735099

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

session_10/answers/A5.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1-
# 5. Write a class which has two methods get_word and print_word.
2-
# - get_word accepts a string from the user and print_word prints the string in upper case.
1+
# 5. Create a class called Upper which has two methods called get_word and print_word.
2+
# - the get_word method should accept a string from the user
3+
# - the print_word method prints the string in upper case.
34

5+
class Upper:
6+
def __init__(self):
7+
self.word = ""
8+
9+
def get_word(self):
10+
self.word = input("Input a word:\n")
11+
12+
def print_word(self):
13+
print(self.word.upper())
14+
15+
word1 = Upper()
16+
word1.get_word()
17+
word1.print_word()

0 commit comments

Comments
 (0)
0