示例#1
0
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
示例#3
0
 def test_number_is_int(self):
     self.assertIsInstance(isPrime(int), "The input must be an integer")
示例#4
0
 def test_input_must_be_a_number(self):
     self.assertEqual(isPrime(1), "The input must be a number only")
示例#5
0
 def test_no_string(self):
     self.assertEqual(isPrime("a"), "Cannot allow letters")
示例#6
0
 def test_input_must_not_be_float(self):
     self.assertEqual(isPrime(10.5), "The number must be a whole number")
示例#7
0
 def test_input_must_not_be_a_boolean(self):
     self.assertEqual(isPrime(True), "The number must not be a boolean")
示例#8
0
 def test_not_big_integer(self):
     self.assertTrue(isPrime(isPrime > 1000),
                     'large numbers not allowed!!!')
示例#9
0
 def test_input_must_not_be_a_tuple(self):
     self.assertEqual(isPrime((100)), "The number must be a whole number")
示例#10
0
 def test_no_list(self):
     self.assertEqual(isPrime([24]), "Cannot allow lists")
示例#11
0
 def test_input_must_be_a_number(self):
     self.assertEqual(isPrime("abc"),"Dont input alphabets")
示例#12
0
def prime_lst(n):
    lst = [x for x in range(3, n, 2) if isPrime(x)]
    lst.insert(0, 2)
    return lst