def len_seg(): print("Segment has two points") print("A[x1,y1]") print("B[x2,y2]") print("Insert the data") x1 = input("x1 = ") y1 = input("y1 = ") x2 = input("x2 = ") y2 = input("y2 = ") try: x1 = float(x1) x2 = float(x2) y1 = float(y1) y2 = float(y2) except ValueError: print("[!] At least one of the inputted variables is not a number") exit() seg_length = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) print("test " + str(seg_length ** 2)) prime = prime_number.isPrime(int(seg_length)) print(prime) if prime == 0: print("Length of this segment: " + str(seg_length)) print("Or just simply...") root = str(square_service.sqr_svc(float(seg_length ** 2))) if (str(int((float(seg_length ** 2)))) in root): print(chr(8730) + str(int(seg_length ** 2))) else: print(root) if prime == 1: print("Length of this segment: " + str(seg_length)) print("Or " + chr(8730) + str(int(seg_length ** 2)))
def prime_lst(n): lst = [x for x in range(3, n, 2) if isPrime(x)] lst.insert(0,2) return lst
def test_number_is_int(self): self.assertIsInstance(isPrime(int), "The input must be an integer")
def test_input_must_be_a_number(self): self.assertEqual(isPrime(1), "The input must be a number only")
def test_no_string(self): self.assertEqual(isPrime("a"), "Cannot allow letters")
def test_input_must_not_be_float(self): self.assertEqual(isPrime(10.5), "The number must be a whole number")
def test_input_must_not_be_a_boolean(self): self.assertEqual(isPrime(True), "The number must not be a boolean")
def test_not_big_integer(self): self.assertTrue(isPrime(isPrime > 1000), 'large numbers not allowed!!!')
def test_input_must_not_be_a_tuple(self): self.assertEqual(isPrime((100)), "The number must be a whole number")
def test_no_list(self): self.assertEqual(isPrime([24]), "Cannot allow lists")
def test_input_must_be_a_number(self): self.assertEqual(isPrime("abc"),"Dont input alphabets")
def prime_lst(n): lst = [x for x in range(3, n, 2) if isPrime(x)] lst.insert(0, 2) return lst