Best Python code snippet using pandera_python
main.py
Source:main.py
...18 return True19 else:20 print(f'{a} менÑÑе или Ñавен 0')21 return False22def check_input(a):23 if is_number(a):24 if check_plus(float(a)):25 return True26 else:27 return False28 else:29 return False30def circle_input():31 a = input('ÐÑогÑамма поддеÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð²ÑÑиÑÐ»ÐµÐ½Ð¸Ñ Ð¿Ð»Ð¾Ñади и диамеÑÑа кÑÑга.\nÐÐ»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ ÑезÑлÑÑаÑов введиÑе ÑадиÑÑ '32 'кÑÑга:\n')33 if check_input(a):34 return float(a)35 else:36 return False37def circle_calc(a):38 circle = Circle(a)39 Circle.name()40 print(f'ÐлоÑÐ°Ð´Ñ ÑигÑÑÑ: {circle.area()}\nÐиамеÑÑ ÐºÑÑга: {circle.diameter()}')41def square_input():42 a = input(43 'ÐÑогÑамма поддеÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð²ÑÑиÑÐ»ÐµÐ½Ð¸Ñ Ð¿Ð»Ð¾Ñади и диагонали квадÑаÑа.\nÐÐ»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ ÑезÑлÑÑаÑов введиÑе '44 'ÑÑоÑÐ¾Ð½Ñ ÐºÐ²Ð°Ð´ÑаÑа:\n')45 if check_input(a):46 return float(a)47 else:48 return False49def square_calc(a):50 square = Square(a)51 Square.name()52 print(f'ÐлоÑÐ°Ð´Ñ ÑигÑÑÑ: {square.area()}\nÐÐ¸Ð°Ð³Ð¾Ð½Ð°Ð»Ñ ÐºÐ²Ð°Ð´ÑаÑа: {square.diagonal()}')53def rectangle_input():54 a = input(55 'ÐÑогÑамма поддеÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð²ÑÑиÑÐ»ÐµÐ½Ð¸Ñ Ð¿Ð»Ð¾Ñади и диагонали пÑÑмоÑголÑника.\nÐÐ»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ ÑезÑлÑÑаÑов введиÑе '56 'ÑнаÑала пеÑвÑÑ ÑÑоÑÐ¾Ð½Ñ Ð¿ÑÑмоÑголÑника:\n')57 if check_input(a):58 b = input('ÐаÑем вÑоÑÑÑ:\n')59 if check_input(b):60 return float(a), float(b)61 else:62 return False, False63 else:64 return False, False65def rectangle_calc(a, b):66 rectangle = Rectangle(a, b)67 Rectangle.name()68 print(f'ÐлоÑÐ°Ð´Ñ ÑигÑÑÑ: {rectangle.area()}\nÐÐ¸Ð°Ð³Ð¾Ð½Ð°Ð»Ñ Ð¿ÑÑмоÑголÑника: {rectangle.diagonal()}')69def triangle_input():70 a = input(71 'ÐÑогÑамма поддеÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð²ÑÑиÑÐ»ÐµÐ½Ð¸Ñ Ð¿Ð»Ð¾Ñади и медиан ÑÑеÑголÑника.\nÐÐ»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ ÑезÑлÑÑаÑов введиÑе '72 'ÑнаÑала пеÑвÑÑ ÑÑоÑÐ¾Ð½Ñ ÑÑеÑголÑника:\n')73 if check_input(a):74 b = input('ÐÑоÑÑÑ:\n')75 if check_input(b):76 c = input('Ð ÑÑеÑÑÑ:\n')77 if check_input(c):78 return float(a), float(b), float(c)79 else:80 return False, False, False81 else:82 return False, False, False83 else:84 return False, False, False85def triangle_calc(a, b, c):86 triangle = Triangle(a, b, c)87 Triangle.name()88 print(f'ÐлоÑÐ°Ð´Ñ ÑигÑÑÑ: {triangle.area()}\nÐÐµÐ´Ð¸Ð°Ð½Ñ ÑÑеÑголÑника: {triangle.medians()}')89def trapezoid_input():90 a = input(91 'ÐÑогÑамма поддеÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð²ÑÑиÑÐ»ÐµÐ½Ð¸Ñ Ð¿Ð»Ð¾Ñади и ÑÑедней линии ÑÑапеÑии.\nÐÐ»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ ÑезÑлÑÑаÑов введиÑе '92 'ÑнаÑала веÑÑ
нее оÑнование ÑÑапеÑии:\n')93 if check_input(a):94 b = input('ÐÐ´Ð½Ñ Ð±Ð¾ÐºÐ¾Ð²ÑÑ ÑÑоÑонÑ:\n')95 if check_input(b):96 c = input('Ðижнее оÑнование:\n')97 if check_input(c):98 d = input('ÐÑоÑÑÑ Ð±Ð¾ÐºÐ¾Ð²ÑÑ ÑÑоÑонÑ:\n')99 if check_input(d):100 return float(a), float(b), float(c), float(d)101 else:102 return False, False, False, False103 else:104 return False, False, False, False105 else:106 return False, False, False, False107 else:108 return False, False, False, False109def trapezoid_calc(a, b, c, d):110 trapezoid = Trapezoid(a, b, c, d)111 Trapezoid.name()112 print(f'ÐлоÑÐ°Ð´Ñ ÑигÑÑÑ: {trapezoid.area()}\nСÑеднÑÑ Ð»Ð¸Ð½Ð¸Ñ ÑÑапеÑии: {trapezoid.middle_line()}')113def rhombus_input():114 a = input(115 'ÐÑогÑамма поддеÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð²ÑÑиÑÐ»ÐµÐ½Ð¸Ñ Ð¿Ð»Ð¾Ñади и ÑÑоÑÐ¾Ð½Ñ Ñомба.\nÐÐ»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ ÑезÑлÑÑаÑов введиÑе ÑнаÑала '116 'пеÑвÑÑ Ð´Ð¸Ð°Ð³Ð¾Ð½Ð°Ð»Ñ Ñомба:\n')117 if check_input(a):118 b = input('ÐаÑем вÑоÑÑÑ:\n')119 if check_input(b):120 return float(a), float(b)121 else:122 return False, False123 else:124 return False, False125def rhombus_calc(a, b):126 rhombus = Rhombus(a, b)127 Rhombus.name()128 print(f'ÐлоÑÐ°Ð´Ñ ÑигÑÑÑ: {rhombus.area()}\nСÑоÑона Ñомба: {rhombus.side()}')129def sphere_input():130 a = input('ÐÑогÑамма поддеÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð²ÑÑиÑÐ»ÐµÐ½Ð¸Ñ Ð¿Ð»Ð¾Ñади и обÑема ÑÑеÑÑ.\nÐÐ»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ ÑезÑлÑÑаÑов введиÑе '131 'ÑадиÑÑ ÑÑеÑÑ:\n')132 if check_input(a):133 return float(a)134 else:135 return False136def sphere_calc(a):137 sphere = Sphere(a)138 Sphere.name()139 print(f'ÐлоÑÐ°Ð´Ñ ÑигÑÑÑ: {sphere.area()}\nÐбÑем ÑÑеÑÑ: {sphere.volume()}')140def cube_input():141 a = input('ÐÑогÑамма поддеÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð²ÑÑиÑÐ»ÐµÐ½Ð¸Ñ Ð¿Ð»Ð¾Ñади и обÑема кÑба.\nÐÐ»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ ÑезÑлÑÑаÑов введиÑе '142 'ÑÑоÑÐ¾Ð½Ñ ÐºÑба:\n')143 if check_input(a):144 return float(a)145 else:146 return False147def cube_calc(a):148 cube = Cube(a)149 Cube.name()150 print(f'ÐлоÑÐ°Ð´Ñ ÑигÑÑÑ: {cube.area()}\nÐбÑем кÑба: {cube.volume()}')151def parallelepiped_input():152 a = input('ÐÑогÑамма поддеÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð²ÑÑиÑÐ»ÐµÐ½Ð¸Ñ Ð¿Ð»Ð¾Ñади и обÑема пÑÑмоÑголÑного паÑаллелепипеда.\nÐÐ»Ñ '153 'полÑÑÐµÐ½Ð¸Ñ ÑезÑлÑÑаÑов введиÑе Ð´Ð»Ð¸Ð½Ñ Ð¿ÐµÑвой ÑÑоÑонÑ:\n')154 if check_input(a):155 b = input('ÐÑоÑой:\n')156 if check_input(b):157 c = input('ТÑеÑÑей:\n')158 if check_input(c):159 return float(a), float(b), float(c)160 else:161 return False, False, False162 else:163 return False, False, False164 else:165 return False, False, False166def parallelepiped_calc(a, b, c):167 parallelepiped = Parallelepiped(a, b, c)168 Parallelepiped.name()169 print(f'ÐлоÑÐ°Ð´Ñ Ð¿Ð°Ñаллелепипеда: {parallelepiped.area()}\nÐбÑем паÑаллелепипеда: {parallelepiped.volume()}')170def pyramid_input():171 a = input('ÐÑогÑамма поддеÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð²ÑÑиÑÐ»ÐµÐ½Ð¸Ñ Ð¿Ð»Ð¾Ñади и обÑема ÑеÑÑÑеÑ
ÑголÑной пиÑамидÑ.\nÐÐ»Ñ '172 'полÑÑÐµÐ½Ð¸Ñ ÑезÑлÑÑаÑов введиÑе Ð´Ð»Ð¸Ð½Ñ Ð¿ÐµÑвой ÑÑоÑÐ¾Ð½Ñ Ð¾ÑнованиÑ:\n')173 if check_input(a):174 b = input('ÐÑоÑой:\n')175 if check_input(b):176 c = input('Рбоковой ÑÑоÑонÑ:\n')177 if check_input(c):178 return float(a), float(b), float(c)179 else:180 return False, False, False181 else:182 return False, False, False183 else:184 return False, False, False185def pyramid_calc(a, b, c):186 pyramid = Pyramid(a, b, c)187 Pyramid.name()188 print(f'ÐлоÑÐ°Ð´Ñ Ð¿Ð°Ñаллелепипеда: {pyramid.area()}\nÐбÑем паÑаллелепипеда: {pyramid.volume()}')189def cylinder_input():190 a = input('ÐÑогÑамма поддеÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð²ÑÑиÑÐ»ÐµÐ½Ð¸Ñ Ð¿Ð»Ð¾Ñади и обÑема ÑилиндÑа.\nÐÐ»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ ÑезÑлÑÑаÑов '191 'введиÑе ÑадиÑÑ Ð¾ÑнованиÑ:\n')192 if check_input(a):193 b = input('РвÑÑоÑÑ:\n')194 if check_input(b):195 return float(a), float(b)196 else:197 return False, False198 else:199 return False, False200def cylinder_calc(a, b):201 cylinder = Cylinder(a, b)202 Cylinder.name()203 print(f'ÐлоÑÐ°Ð´Ñ ÑилиндÑа: {cylinder.area()}\nÐбÑем ÑилиндÑа: {cylinder.volume()}')204def cone_input():205 a = input('ÐÑогÑамма поддеÑÐ¶Ð¸Ð²Ð°ÐµÑ Ð²ÑÑиÑÐ»ÐµÐ½Ð¸Ñ Ð¿Ð»Ð¾Ñади и обÑема конÑÑа.\nÐÐ»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ ÑезÑлÑÑаÑов введиÑе '206 'ÑадиÑÑ Ð¾ÑнованиÑ:\n')207 if check_input(a):208 b = input('РвÑÑоÑÑ:\n')209 if check_input(b):210 return float(a), float(b)211 else:212 return False, False213 else:214 return False, False215def cone_calc(a, b):216 cone = Cone(a, b)217 Cone.name()218 print(f'ÐлоÑÐ°Ð´Ñ ÑилиндÑа: {cone.area()}\nÐбÑем ÑилиндÑа: {cone.volume()}')219start = True220while start:221 choice = input(222 'ÐÑбеÑеÑе ÑигÑÑÑ Ð´Ð»Ñ Ð²ÑÑиÑлений:\n1. ÐÑÑг;\n2. ÐвадÑаÑ;\n3. ÐÑÑмоÑголÑник;\n4. ТÑеÑголÑник;\n5. ТÑапеÑиÑ;\n6. '223 'Ромб;\n7. СÑеÑа;\n8. ÐÑб;\n9. ÐÑÑмоÑголÑнÑй паÑаллелепипед;\n10. ЧеÑÑÑеÑ
ÑголÑÐ½Ð°Ñ Ð¿Ð¸Ñамида;\n11. '...
test_check_input.py
Source:test_check_input.py
...11 def test_integers_simple(self):12 from src.check_input import check_input13 options = [-220,-22,-11,-2,-1,0,1,2,11,22,220]14 for input in options:15 self.assertEqual(input, check_input(input, options))16 def test_integers_part(self):17 from src.check_input import check_input18 options = [-22,-11,-2,-1,0,1,2,11,22]19 for input in [-2,-1,0,1,2]:20 self.assertEqual(input, check_input(input, options))21 def test_integers_mismach1(self):22 from src.check_input import check_input23 options = [1,2]24 input = 1.025 #assert input == check_input(input, options)26 self.assertEqual(input, check_input(input, options))27 input = 2.028 self.assertEqual(input, check_input(input, options))29 def test_integers_mishmash2(self):30 from src.check_input import check_input31 options = [-22,-11,-2,-1,0,1,2,11,22]32 for input in [-22.0,-11.0,-2.0,-1.0,0.0,1.0,2.0,11.0,22.0]:33 self.assertEqual(input, check_input(input, options))34 def test_integers_random(self):35 from src.check_input import check_input36 #options = np.random.choice(np.random.randint(0,1000000,10000),10,replace=False)37 options = [int(a) for a in np.random.randint(0,1000000,1000)]38 options = list(np.random.randint(0,1000000,1000))39 print(options[0].__class__)40 for input in options:41 self.assertEqual(input, check_input(input, options))42 def test_integers_mishmash3(self):43 from src.check_input import check_input44 options = ['-22','-11','-2','-1','0','1','2','11','22']45 options.extend([-22,-11,-2,-1,0,1,2,11,22])46 print(options)47 for input in options:48 with self.assertRaises(TypeError):49 check_input(input, options)50 51 def test_floats_simple(self):52 from src.check_input import check_input53 options = [-220.9,-22.8,-11.7,-2.6,-1.5,0.4,1.3,2.2,11.1,22.0, 220.99]54 for input in options:55 self.assertEqual(input, check_input(input, options))56 def test_floats_part(self):57 from src.check_input import check_input58 options = [-22.0,-11.0,-2.0,-1.0,0.0,1.0,2.0,11.0,22.0]59 for input in [-2,-1,0,1,2]:60 self.assertEqual(input, check_input(input, options))61 def test_floats_mishmash1(self):62 from src.check_input import check_input63 options = [1.0,2.0]64 input = 165 #assert input == check_input(input, options)66 self.assertEqual(input, check_input(input, options))67 input = 268 self.assertEqual(input, check_input(input, options))69 def test_floats_mishmash2(self):70 from src.check_input import check_input71 options = [-22,-11,-2,-1,0,1,2,11,22]72 for input in [-22.0,-11.0,-2.0,-1.0,0.0,1.0,2.0,11.0,22.0]:73 self.assertEqual(input, check_input(input, options))74 def test_floats_random(self):75 from src.check_input import check_input76 options = list(np.random.random(1000)*1000000)77 print(options[0].__class__)78 for input in options:79 self.assertEqual(input, check_input(input, options))80 def test_floats_mishmash3(self):81 from src.check_input import check_input82 options = [-22.0,-11.0,-2.0,-1.0,0.0,1.0,2.0,11.0,22.0]83 for input in options:84 self.assertEqual(input, check_input(int(input), options))85 def test_strings_simple(self):86 from src.check_input import check_input87 options = ["ahoj","alabama"]88 for input in options:89 self.assertEqual(input, check_input(input, options))90 def test_strings_capital_letters(self):91 from src.check_input import check_input92 options = ["Ahoj","ahoj"]93 self.assertEqual("ahoj", check_input("ahoj", options))94 self.assertEqual("Ahoj", check_input("Ahoj", options))95 self.assertEqual("ahoj", check_input("ahoj", options, False))96 self.assertEqual("Ahoj", check_input("Ahoj", options, False))97 def test_strings_parts1(self):98 from src.check_input import check_input99 options = ["Ahoj","ahoj",'A','a']100 #assert input == check_input(input, options)101 for input in options:102 self.assertEqual(input, check_input(input, options))103 def test_strings_parts2(self):104 from src.check_input import check_input105 options = ["Ahoj","ahoj",'Ah','ah']106 #assert input == check_input(input, options)107 for input in options:108 print(input, check_input(input[0], options))109 self.assertEqual(None, check_input(input[0], options))110 def test_strings_mishmash3(self):111 from src.check_input import check_input112 options = ["Ahoj","ahoj"]113 for input in [-2.0,-1.0,0.0,1.0,2.0]:114 with self.assertRaises(TypeError):...
testing.py
Source:testing.py
...15 self.assertRaises(ValueError, calc_charge, '5pm', '1am', '88pm')16 self.assertRaises(ValueError, calc_charge, '-5pm', '1am', '88pm')17 self.assertRaises(ValueError, calc_charge, '5pm', '-1am', '88pm')18 self.assertRaises(ValueError, calc_charge, '5pm', '1am', '-8pm')19 def test_check_input(self):20 # testing for errors related to input21 self.assertRaises(ValueError, check_input, 'apm', '4am', '9pm')22 self.assertRaises(ValueError, check_input, '5pm', 'aam', '9pm')23 self.assertRaises(ValueError, check_input, '7pm', '2am', 'apm')24 self.assertRaises(TypeError, check_input, True, '12am', '8pm')25 self.assertRaises(TypeError, check_input, '6pm', 11, '8pm')26 self.assertRaises(TypeError, check_input, '8pm', '12a', False)27 self.assertRaises(ValueError, check_input, '4pm', '1am', '8pm')28 self.assertRaises(ValueError, check_input, '5pm', '5am', '8pm')29 self.assertRaises(ValueError, check_input, '5pm', '2am', '3pm')30 self.assertRaises(ValueError, check_input, '5pm', '2am', '4am')31 self.assertRaises(ValueError, check_input, '5pm', '2am', '12am')32 self.assertRaises(ValueError, check_input, '5pm', '2am', '12pm')33 self.assertRaises(ValueError, check_input, '', '1am', '9pm')...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!