Question: hello, need help with python 1. The is_palindrome function checks if a string is a palindrome. A palindrome is a string that can be equally
hello, need help with python
1. The is_palindrome function checks if a string is a palindrome. A palindrome is a string that can be equally read from left to right or right to left, omitting blank spaces, and ignoring capitalization. Examples of palindromes are words like kayak and radar, and phrases like "Never Odd or Even". Fill in the blanks in this function to return True if the passed string is a palindrome, False if not. m 1 - def is palindrome (input_string): # We'll create two strings, to compare them new_string="" reverse_string = " 5 # Traverse through each letter of the input string for : # Add any non-blank letters to the # end of one string, and to the front # of the other string. if : new_string= reverse_string = 13 # Compare the strings 14 if __: return True return false 12 15 16 17 18 19 print(is_palindrome ("Never Odd or Even")) # Should be True print(is_palindrome ("abc")) # should be False print(is palindrome ("kayak")) # Should be True 20 2. Using the format method, fill in the gaps in the convert_distance function so that it returns the phrase "X miles equals Y km", with Y having only 1 decimal place. For example, convert_distance(12) should return "12 miles equals 19.2 km". 1 an AWN def convert_distance (miles): km = miles * 1.6 result = "{} miles equals {_} km". _ return result 7 8 print(convert_distance(12)) # should be: 12 miles equals 19.2 km print(convert_distance(5.5)) # should be: 5.5 miles equals 8.8 km print(convert distance(11)) # Should be: 11 miles equals 17.6 km
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
