Problem 4: write a complete program (30 points) For this problem, you must write
ID: 3805098 • Letter: P
Question
Problem 4: write a complete program (30 points) For this problem, you must write a complete program. That includes a docstring, a def mainO, any necessary library imports, etc. To get full credit, your functions should call each other where appropriate to avoid duplicating work! Your program should contain the following functions: isLower: Takes 1 input parameter, a string. Returns True if the string is all lowercase and False otherwise. If the string is empty, function should return True. Examples of calling this function: isLover("olympus has fallen") returns True be cause all characters are lowercase; isLower("Olympus has fallen") returns False because one character is uppercase (the letter o). Note: Non-alphabetic characters should be ignored. For example calling isLower("olympus has fallen 3 times! still returns True because numbers and exclamation marks can be ignored. get Movie Name: Does not have any input parameter. Repeatedly prompts the user for a movie's name until the user enters a string that is not all lowercase Calls is Lower to check each of the user's entries Returns the movie name Each line of user input should count as a single name, even if it has multiple words. For example, the following sequence of user input (in italics and underlined): Enter a movie name mission impossible 2 Enter a movie name batman begins Enter a movie name The force Awakens should return the string The force Avakens main: Calls get Movie Name to get a movie name from the user. Prints each word in the movie name that is not all lowercase, in the same line. For example, for the movie name The force Awakens, the output of the main function will be The AwakensExplanation / Answer
def isLower(s):
if len(s)==0:
return True
if s.lower() == s:
return True
return False
def getMovieName():
s = ""
while True:
s = raw_input("Ente a movie name:")
if isLower(s):
print("Enter a name without all lowercase characters.")
continue
break
return s
def main():
s = getMovieName()
s = s.split()
ans= ""
for a in s:
if not (isLower(a)):
ans = ans + a+" "
print(ans)
main()
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.