Problem 2 Assume s is a string of lower case personalities. Write a routine that prints the variety of times the string ' lol' occurs in s For instance, if s= 'azclololegghakl', then your routine should print S Number of times lol occu rs is: 2 Problem 3 Assume s is a string of lower case characters Write a regime that prints the longest substring of s in which the letters occur in alphabetical order. For instance, if s ='wqlnhahjkojlzqkhizkq', then your regime must print Longest substring in alphabetical order is: ahjko In the situation of ties, print the initially substring. For example, ifs then your program must print abcbcd' Longest substring in alphabetical order is: abc


You are watching: Assume s is " abc ", the method ________ returns a new string "abc".

Problem2: Code in python:

#string = "azclololegghaki"string = input("Get in a string: ")sub = input("Enter a substring: ")sub = "lol"count = 0ind = 0for i in string:count += string.count(sub,ind,ind+3)ind += 1print("the number of times substring occures in stringis:",count)

*

OUTPUT:

*

Problem2: Code in python:

#s = "wqlnhahjkojlzqkhizkq"s = input("Get in the string: ")maxString = ""maxCount = 0 ;

dimension = len(s)string = ""string += s<0>i=1;preChar = s<0>while(iif(s>s):string+=selse:tempSize = len(string)if(tempSize>maxCount):maxString = stringmaxCount = tempSizestring = selse:string = si+=1print("Longest substring in alphabatical order is:",maxString)

*

OUTPUT:

*
*


#string string sub = input("Enter a substring: ") "azclololegghaki " inputC"Enter a string: ") "lol" sub count ind = 0 for i in string: string.count(sub,ind,ind+3) count ind += 1 print("the variety of times substring oCcures in string is:",count)
input Go into a string: azclololegghaki Go into a substring: lol the number of times substring occures in string is: 2 ...Program finished via exit code 0 Press ENTER to leave console.
"wqlnhahjkojlzqkhizka" S = input("Get in the string: ") 10 #s = 11 maxString 13 maxCount = 0 ; 12 14 15 dimension = len(s) 16 string 17 string 18 i=1; 19 preChar = s<0> 20 while(is): string+=s else: 21 22 23 Len(string if(tempSize>maxCount): string maxCount = tempSize s 24 tempSize maxString string else: string s it=1 32 printC"Longest substring in alphabatical order is: ",maxString) 25227238N3
Enter the string: wqlnhahjkojlzqkhizką Longest substring in alphabatical order is: ahjko ... Program finiburned via leave code 0 Press ENTER to departure consingle.
input Get in the string: abcbcd Longest substring in alphabatical order is: abc |...Program finished via departure code 0 Press ENTER to departure console.


See more: How To Get Free Vc On Nba 2K17 Cheats & Guides, Jjplayz Nba 2K17 Cheats & Guides

report this ad