Require Code is below def sum(a, b): return (a + b) a = int(input('Enter 1st number: ')) b = int(input('Enter 2nd number: ')) print(f'Sum of {a} and {b} is {sum(a, b)}')
String Functions # b = '''onam"s and onam's''' # print (b) # concatenating two strings # greeting = "good morning, " # name = "Onam" # c = greeting + name # print(c) # sring index name = "Onam" # print (name[4]) # print (name[0:4]) # print (name[:4]) # is same as name[0:4] # print (name[-4:-2]) # is same as name[2:4] # skip string name = "Awesome" d = name[0:5:2] print (d) String function ''' story = "once upon a time there was a youtuber who upload python course with notes" # # String function # print (len(story)) # print (story.endswith("notes")) # print (story.count("a")) # print (story.capitalize()) print (story.find("who")) print (story.replace("youtuber", "onam")) ''' story = "onam is good. \nhe\t is\' go\\od" # \n= new line \t=tab \'=sigle quotes print (story)
Comments
Post a Comment