def test_pascal(self): test_1 = pascal.pascal(0) self.assertEqual(test_1, [1]) test_2 = pascal.pascal(1) self.assertEqual(test_2, [1,1]) test_3 = pascal.pascal(2) self.assertEqual(test_3, [1,2,1]) test_4 = pascal.pascal(3) self.assertEqual(test_4, [1,3,3,1]) test_5 = pascal.pascal(10) self.assertEqual(test_5, [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1])
def test_pascal(self): self.assertEqual(p.pascal(3, 3), 1) self.assertEqual(p.pascal(0, 0), 1) self.assertEqual(p.pascal(4, 2), 6) self.assertEqual(p.pascal(-2, 3), 0) self.assertEqual(p.pascal(2, -1), 0) self.assertEqual(p.pascal(-6, -6), 0) self.assertEqual(p.pascal(7, 2), 21)
def test_pascal_speed(self): t0 = time.time() pascal.pascal(10000) t1 = time.time() total_time = t1 - t0 print("\nv1 time: %ss" % str(total_time))
backward((meret / 2) + 8) left(90) backward(meret / 2) pendown() def szoveges_negyzetek(y, meret, szin, szovegek): x = (len(szovegek) * meret) / 2 j = 0 for i in range(-x, x, meret): penup() setpos(i, y) pendown() szoveges_negyzet(szovegek[j], meret, szin) j += 1 hideturtle() width(2) db = 8 list = [1] y = 200 szoveges_negyzetek(y, 50, "blue", map(str, list)) for i in range(1, db + 1): list = pascal(list) y = y - 50 szoveges_negyzetek(y, 50, "blue", map(str, list)) exitonclick()
def test_pascal(arg, expected): assert pascal(arg) == expected
def test_five(self): assert pascal(5) s== [[1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]][[1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]][[1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]
#!/usr/bin/python #acleetus from factor import factor from triangle import triangle from doubling import doubling from factorial import factorial from pascal import pascal from occurrences import num_occurrences print factor(60) print factor(45) print factor(35) print factor(13) triangle(3) triangle(5) print doubling(0.1) print doubling(0.05) print doubling(0.01) print factorial(4) print factorial(0) pascal(10) print num_occurrences(["a", "b", "a", "b", "c", "b", "d", "e"], "b")