def palindromeprime(N, M): if N > M: quit() elif palindrome(str(N)): if prime(int(N), int(N - 1)) > 0: print(N) return palindromeprime(N + 1, M) else: return palindromeprime(N + 1, M) else: return palindromeprime(N + 1, M)
def palindrome_case(x): assert palindrome("racecar") == 1 assert palindrome("") == 1 assert palindrome("hello") == 0 assert palindrome("mom") == 1 assert palindrome("a") == 1 assert palindrome("h a h a") == 0
def test_correct_output(self): self.assertEqual(palindrome("racecar"), True) self.assertEqual(palindrome("tacocat"), True) self.assertEqual(palindrome("level"), True) self.assertEqual(palindrome("banana"), False)
def setup(self): self.palindrome = palindrome()
def test_empty(self): self.assertTrue (palindrome (""))
def test_five(): assert palindrome(42) == -1
def test_seven(): assert palindrome(False) == -1
def test_two_letters(self): self.assertTrue (palindrome ("vv"))
def test_three(): assert palindrome("level") == True
def test_not(self): self.assertFalse (palindrome (remove_spaces ("i'm not a palindrome")))
def test_hard_1(self): s = "abacabadabacaba" self.assertEqual(palindrome(s), "abacabadabacaba")
def test_rat(self): self.assertTrue (palindrome (remove_spaces ("Was It a Rat I saW")))
def test_rat_diff_case(self): self.assertFalse (palindrome (remove_spaces ("was It a Rat I saW")))
def test_odd_even(self): self.assertTrue (palindrome (remove_spaces ("never odd or even")))
def test_toyota_with_spaces(self): self.assertTrue (palindrome (remove_spaces ("a toyota")))
def test_toyota(self): self.assertTrue (palindrome ("atoyota"))
def test_type_handling(self): self.assertEqual(palindrome(42), -1) self.assertEqual(palindrome(26.4), -1) self.assertEqual(palindrome(False), -1)
def test_one(): assert palindrome("racecar") == True
def test_special_characters_palindrome(self): self.assertTrue (palindrome (remove_spaces ("! 9 & 9 !")))
def test_one_letter(self): self.assertTrue (palindrome ("v"))
def test_hard_2(self): s = "abacabazzzzzzz" self.assertEqual(palindrome(s), "abacaba")
def test_special_characters_no_palindrome(self): self.assertFalse (palindrome (remove_spaces ("! 9 & 8 !")))
def test_two(): assert palindrome("tacocat") == True
def test_raise_typerror_float(self): self.assertRaises (TypeError, lambda: palindrome (1.0))
def test_four(): assert palindrome("banana") == False
def test_raise_typerror_list(self): self.assertRaises (TypeError, lambda: palindrome ([1,2,3]))
def test_six(): assert palindrome(26.4) == -1
def test_palindrome(): expected_result = bool(input('What is the expected_result[1 or 0]: ')) assert (palindrome() == expected_result)
def test_palindrome(self): expected_result = bool(input('What is the expected_result[1 or 0]: ')) self.assertEqual(palindrome(), expected_result)
try_except_demo() elif choice == 0 or choice == 13: print("========read file Example========") write_file_demo() read_file_demo() append_file_demo() read_file_demo() elif choice == 0 or choice == 14: print("========Class Example========") class_demo() elif choice == 0 or choice == 15: print("========String format Example========") string_format_demo() elif choice == 0 or choice == 16: print("======== rock paper scissor Example========") play_game() elif choice == 0 or choice == 17: print("========generate Password Example========") print(gen_password(8)) elif choice == 0 or choice == 18: print("========guessing Example========") guessing_game() elif choice == 0 or choice == 19: print("========palindrome Example========") palindrome() elif choice == 0 or choice == 20: print("========tic tac toe========") play_tic_tac_toe() else: print("Exiting...!!")
from reverse_digit import * from reverse_number import * from reverse_string import * from number_of_word import * from palindrome import * reverse_digit(56) reverse_num(5) reverse_str('hello') a_word('hello you') palindrome("ressasser")
def test_none(self): self.assertFalse (palindrome (None))