Ran 2 tests in 0.001s
OK
2.Mantiqiy qiymatlarni tekshirish:
def tubSonmi(n):
if n==2 or n==3: return True
if n%2==0 or n<2: return False
for i in range(3, int(n**0.5)+1, 2): # faqat toq sonlarni tekshiramiz
if n%i==0:
return False
return True
Test:
import unittest
from tubSonmi import tubSonmi
class tubSonTest(unittest.TestCase):
def test_true(self):
self.assertTrue(tubSonmi(7))
self.assertTrue(tubSonmi(193))
self.assertTrue(tubSonmi(547))
def test_false(self):
self.assertFalse(tubSonmi(6))
self.assertFalse(tubSonmi(265))
self.assertFalse(tubSonmi(489))
unittest.main()
Natija:
Ran 3 tests in 0.001s
OK
3.Mantiqiy qiymatlarni tekshirish:
def tubSonmi(n):
if n==2 or n==3: return True
if n%2==0 or n<2: return False
for i in range(3, int(n**0.5)+1, 2): # faqat toq sonlarni tekshiramiz
if n%i==0:
return False
return True
Test:
import unittest
from tubSonmi import tubSonmi
class tubSonTest(unittest.TestCase):
def test_true(self):
self.assertTrue(tubSonmi(7))
self.assertTrue(tubSonmi(193))
self.assertTrue(tubSonmi(547))
def test_false(self):
self.assertFalse(tubSonmi(6))
self.assertFalse(tubSonmi(265))
self.assertFalse(tubSonmi(489))
unittest.main()
Natija:
Ran 3 tests in 0.001s
OK
4.Modulli yoki iteratsion testlash ma’lumotlar to’plamini yaratish
Do'stlaringiz bilan baham: |