Пример #1
0
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
Пример #3
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)
Пример #4
0
 def setup(self):
     self.palindrome = palindrome()
Пример #5
0
 def test_empty(self):
     self.assertTrue (palindrome (""))
Пример #6
0
def test_five():
    assert palindrome(42) == -1
Пример #7
0
def test_seven():
    assert palindrome(False) == -1
Пример #8
0
 def test_two_letters(self):
     self.assertTrue (palindrome ("vv"))
Пример #9
0
def test_three():
    assert palindrome("level") == True
Пример #10
0
 def test_not(self):
     self.assertFalse (palindrome (remove_spaces ("i'm not a palindrome")))
Пример #11
0
 def test_hard_1(self):
     s = "abacabadabacaba"
     self.assertEqual(palindrome(s), "abacabadabacaba")
Пример #12
0
 def test_rat(self):
     self.assertTrue (palindrome (remove_spaces ("Was It a Rat I saW")))
Пример #13
0
 def test_rat_diff_case(self):
     self.assertFalse (palindrome (remove_spaces ("was It a Rat I saW")))
Пример #14
0
 def test_odd_even(self):
     self.assertTrue (palindrome (remove_spaces ("never odd or even")))
Пример #15
0
 def test_toyota_with_spaces(self):
     self.assertTrue (palindrome (remove_spaces ("a toyota")))
Пример #16
0
 def test_toyota(self):
     self.assertTrue (palindrome ("atoyota"))
Пример #17
0
 def test_type_handling(self):
     self.assertEqual(palindrome(42), -1)
     self.assertEqual(palindrome(26.4), -1)
     self.assertEqual(palindrome(False), -1)
Пример #18
0
def test_one():
    assert palindrome("racecar") == True
Пример #19
0
 def test_special_characters_palindrome(self):
     self.assertTrue (palindrome (remove_spaces ("! 9 & 9 !")))
Пример #20
0
 def test_one_letter(self):
     self.assertTrue (palindrome ("v"))
Пример #21
0
 def test_hard_2(self):
     s = "abacabazzzzzzz"
     self.assertEqual(palindrome(s), "abacaba")
Пример #22
0
 def test_special_characters_no_palindrome(self):
     self.assertFalse (palindrome (remove_spaces ("! 9 & 8 !")))
Пример #23
0
def test_two():
    assert palindrome("tacocat") == True
Пример #24
0
 def test_raise_typerror_float(self):
     self.assertRaises (TypeError, lambda: palindrome (1.0))
Пример #25
0
def test_four():
    assert palindrome("banana") == False
Пример #26
0
 def test_raise_typerror_list(self):
     self.assertRaises (TypeError, lambda: palindrome ([1,2,3]))
Пример #27
0
def test_six():
    assert palindrome(26.4) == -1
Пример #28
0
def test_palindrome():
    expected_result = bool(input('What is the expected_result[1 or 0]: '))
    assert (palindrome() == expected_result)
Пример #29
0
 def test_palindrome(self):
     expected_result = bool(input('What is the expected_result[1 or 0]: '))
     self.assertEqual(palindrome(), expected_result)
Пример #30
0
        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...!!")
Пример #31
0
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")
Пример #32
0
 def test_none(self):
     self.assertFalse (palindrome (None))