Skip to content

Commit dcb2564

Browse files
committed
Assignment 3: Display your address and your marks
1 parent a63e37e commit dcb2564

File tree

3 files changed

+47
-16
lines changed

3 files changed

+47
-16
lines changed

.idea/workspace.xml

Lines changed: 19 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

300_Exercises/Simple/3.Display_name_and_age.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,27 @@ def display_name_age(name,age):
1010
# Enter your name and age with Double white space: Harrish P T 23
1111
# Hi Harrish P T ! and your age is 23.
1212

13+
14+
# Assignment 3:
15+
# Display your address and your marks
16+
def display_address_mark(address,mark):
17+
print(f'Your Address is {address} and your mark is {mark}')
18+
19+
address,mark = input('Enter the Address and your mark with Double white space: ').split(' ')
20+
display_address_mark(address,mark)
21+
22+
# Output:
23+
# Enter the Address and your mark with Double white space: new street 431
24+
# Your Address is new street and your mark is 431
25+
26+
# Total Time Complexity:
27+
28+
# Reading the input takes O(n)O(n) time.
29+
# Splitting the input string takes O(n)O(n) time.
30+
# Printing the output takes O(1)O(1) time.
31+
32+
# Thus, the overall time complexity of the code is:
33+
# O(n)+O(n)+O(1)=O(n)
34+
35+
# Where n is the length of the input string.
36+
# So, the time complexity of this program is O(n).

leet code/75 leetcode/151.Reverse_word_in_a_string.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@
2525
# Output: "example good a"
2626
# Explanation: You need to reduce multiple spaces between two words to a single space in the reversed string.
2727

28-
def reverseWords(s):
28+
def reverse_words(s):
2929
l=s.split()[::-1]
3030
return " ".join(l)
3131
s="a good example"
32-
print(reverseWords(s))
32+
print(reverse_words(s))
3333

3434
# example good a
3535

3636
# 2nd method using while loop
37-
def reverseWords(s):
37+
def reverse_words(s):
3838
result=""
3939
s=s.strip()
4040
i=0
@@ -46,6 +46,6 @@ def reverseWords(s):
4646
return result[:-1]
4747

4848
s=" hello world "
49-
print(reverseWords(s))
49+
print(reverse_words(s))
5050

5151
# world hello

0 commit comments

Comments
 (0)