3 # 4) Define a function that checks if a given string is a palindrome (reads the same forwards and backward) and prints True if the given string is a palindrome and False otherwise. Your program should be case insen for a given string an easy way to get its reversed form is using this shortcut the string[::-1] 5 def is_palindrome (s): 5 # 7 8 9 0 1 s=s.lower () return ==s[::-1] 2 str_1= "level" 3 str_2= "kennedy" I 34 str_3= "madam" 35 print (is_palindrome (str_1)) 36 print (is_palindrome (str_2)) 37 print (is_palindrome (str_3)) 38 # 5) Write a Python program that generates a random number between 1 and 100 and asks the user to guess it.

icon
Related questions
Question
100%
Something is wrong with this code. I get back “true false true” and idk why
34 str_3= "madam"
35 print (is_palindrome (str_1))
Console
+
main.py
22 print("count: ", count)
23 # 4) Define a function that checks if a given string is a palindrome (reads the same forwards and backward)
24 # and prints True if the given string is a palindrome and False otherwise. Your program should be case insensi
25 # for a given string an easy way to get its reversed form is using this shortcut the string [::-1]
26 def is_palindrome (s):
27
s=s.lower ()
28
return s= = s[::-1]
29
3.0
31
32 str_1= "level"
33 str_2= "kennedy"
Terminal
cer a number: 3
d.
36 print (is palindrome(str_2))
37. print (is_palindrome (str_3))
38 # 5) Write a Python program that generates a random number between 1 and 100 and asks the user to guess it.
39 # Provide feedback on whether the guess is too high or too low until the user guesses correctly.
me/main.py 95:55 Spaces: 4 (Auto)
me: kennedy
unt: 2
ue
lse
I
ue
ter Guess:
Lab 5
X Exceeded wall time
이
Challenge
Subm
All cha
Run
Transcribed Image Text:34 str_3= "madam" 35 print (is_palindrome (str_1)) Console + main.py 22 print("count: ", count) 23 # 4) Define a function that checks if a given string is a palindrome (reads the same forwards and backward) 24 # and prints True if the given string is a palindrome and False otherwise. Your program should be case insensi 25 # for a given string an easy way to get its reversed form is using this shortcut the string [::-1] 26 def is_palindrome (s): 27 s=s.lower () 28 return s= = s[::-1] 29 3.0 31 32 str_1= "level" 33 str_2= "kennedy" Terminal cer a number: 3 d. 36 print (is palindrome(str_2)) 37. print (is_palindrome (str_3)) 38 # 5) Write a Python program that generates a random number between 1 and 100 and asks the user to guess it. 39 # Provide feedback on whether the guess is too high or too low until the user guesses correctly. me/main.py 95:55 Spaces: 4 (Auto) me: kennedy unt: 2 ue lse I ue ter Guess: Lab 5 X Exceeded wall time 이 Challenge Subm All cha Run
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer