In: Computer Science
make a python script that has the following typed:
school = “cochise college”
place = “online”
Then do the following with the given parameters.Set the script to have a function that takes two parameters, school and place, have your function return the first 5 characters of each parameter value, utilizing a slice. Change the script to have a function that takes two parameters, school and place, have your function return the first character of each parameter, utilizing an index value. Then, Modify the script to have a function that takes two parameters, school and place, have your function return the last character of the variable place for each parameter, utilizing an index value. Next, modify the script to have a function that takes two parameters, school and place, have your function return the variables school and place in title form. Lastly, modify the python script to have a function that takes two parameters, school and place, have your function check to verify that ‘cochise’ is in the school parameter and ‘online’ is in the place parameter. If it is have the function return, ‘Great you go to Cochise College Online!’, else have the function return, ‘You should check out Cochise College Online!’
#Python code
def firstFiveCharacter(school, place): return school[0:5], place[0:5] def firstCharacter(school, place): return school[0], place[0] def lastCharacter(school, place): return school[len(school)-1], place[len(place)-1] def titleCase(school, place): return school.title(), place.title() def isContains(school, place): if 'cochise' in school and 'online' in place : return "Great you go to Cochise College Online!" else: return "You should check out Cochise College Online!" if __name__ == "__main__": school = "cochise college" place = "online" s, p =firstFiveCharacter(school, place) print("First Five Characters: ") print(s) print(p) fs, fp = firstCharacter(school, place) print("First Characters: ") print(fs) print(fp) ls, lp = lastCharacter(school, place) print("Last characters: ") print(ls) print(lp) print("title Case: ") ts, tp = titleCase(school, place) print(ts) print(tp) print("if School contains 'cochise' and place contains 'online'") msg = isContains(school, place) print(msg)
#Screenshots for indentation help
#output
//if you need any help regarding this solution .......... please leave a comment ...... thanks