F.I.SH._____Qoraqulov Sulaymon______________________
Guruh: _______912-21______________________________
Amaliyot: __13__X_______
Misol: ___4___X_________
Dasturlash tili: ________________
Sinov mavzusi bo’yicha mustaqil 4 tadan misol ishlash.
1.Funksiyani tekshirish:
Funksiya:
def get_full_name(ism, familiya):
return f"{ism} {familiya}".title()
Qolda testlash:
>>> print(get_full_name('alijon','valiyev'))
'Alijon Valiyev'
Avtomatlashtirilgan test:
import unittest
from name import get_full_name
class NameTest(unittest.TestCase):
def test_toliq_ism(self):
formatted_name = get_full_name('alijon','valiyev')
self.assertEqual(formatted_name, 'Alijon Valiyev')
unittest.main()
Natija:
Ran 1 test in 0.001s
OK
Sonlarni tekshirish:
def getArea(r,pi=3.14159):
"""Doiraning yuzini qaytaruvchi funksiya"""
return pi*(r**2)
def getPerimeter(r,pi=3.14159):
"""Doiraning perimetrini qaytaruvchi funksiya"""
return 2*pi*r
Test:
import unittest
from circle import getArea, getPerimeter
class CircleTest(unittest.TestCase):
def test_area(self):
self.assertAlmostEqual(getArea(10), 314.159)
self.assertAlmostEqual(getArea(3),28.27431)
def test_perimeter(self):
self.assertAlmostEqual(getPerimeter(10), 62.8318)
Do'stlaringiz bilan baham: |