From a22205a4234995c393cffc3f15453046dbf1cd3e Mon Sep 17 00:00:00 2001 From: DEVANSH GAJJAR <162860692+DEVANSH-GAJJAR@users.noreply.github.com> Date: Fri, 13 Jun 2025 17:12:39 +0530 Subject: [PATCH 1/6] Update area.py --- maths/area.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/maths/area.py b/maths/area.py index 31a654206977..c95d076f2e49 100644 --- a/maths/area.py +++ b/maths/area.py @@ -4,6 +4,8 @@ """ from math import pi, sqrt, tan +import numpy as np +from scipy.integrate import quad def surface_area_cube(side_length: float) -> float: @@ -264,6 +266,25 @@ def area_rectangle(length: float, width: float) -> float: return length * width +def area_of_parabola(x,a,b,c): + """ + Area under the parabola y = 1x² + 0x + 0 from x = 0 to x = 2 is 2.666666666666667 + """ + return a * x**2 + b * x + c + + def area_under_parabola(a, b, c, x1, x2): + area, _ = quad(parabola, x1, x2, args=(a, b, c)) + return area + #example usage + a = 1 + b = 0 + c = 0 + x1 = 0 + x2 = 2 + +area = area_under_parabola(a, b, c, x1, x2) +print(f"Area under the parabola y = {a}x² + {b}x + {c} from x = {x1} to x = {x2} is {area}") + def area_square(side_length: float) -> float: """ Calculate the area of a square. From feb5296d38e62db2292ccd6b702a81376861fa76 Mon Sep 17 00:00:00 2001 From: DEVANSH GAJJAR <162860692+DEVANSH-GAJJAR@users.noreply.github.com> Date: Mon, 16 Jun 2025 21:41:40 +0530 Subject: [PATCH 2/6] Add files via upload --- dynamic_programming/lucas_function.py | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 dynamic_programming/lucas_function.py diff --git a/dynamic_programming/lucas_function.py b/dynamic_programming/lucas_function.py new file mode 100644 index 000000000000..9b5d24c25b59 --- /dev/null +++ b/dynamic_programming/lucas_function.py @@ -0,0 +1,28 @@ +#Giving the output +def lucas_func(n): + #PREDFINING THE VALUES + a = 2 + b = 1 + + if n == 0: + return a + + # GENERATING THE NUMBER + for i in range(2, n + 1): + c = a + b + a = b + b = c + + return b + +# USER INPUT +n = int(input("Enter the position n to find the nth Lucas Number: ")) +print(f"The {n}th Lucas Number is: {lucas_func(n)}") + +""" + +THE OUTPUT:- +Enter the position n to find the nth Lucas Number: 6 +The 6th Lucas Number is: 18 + +""" \ No newline at end of file From bfce12bc50ed1f7ac9e3ee93c50003ad25d452ae Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 16:12:48 +0000 Subject: [PATCH 3/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- dynamic_programming/lucas_function.py | 21 +++++++++++---------- maths/area.py | 8 ++++---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/dynamic_programming/lucas_function.py b/dynamic_programming/lucas_function.py index 9b5d24c25b59..f016e54d3a26 100644 --- a/dynamic_programming/lucas_function.py +++ b/dynamic_programming/lucas_function.py @@ -1,28 +1,29 @@ -#Giving the output +# Giving the output def lucas_func(n): - #PREDFINING THE VALUES + # PREDFINING THE VALUES a = 2 b = 1 - + if n == 0: return a - - # GENERATING THE NUMBER + + # GENERATING THE NUMBER for i in range(2, n + 1): c = a + b a = b b = c - + return b - -# USER INPUT + + +# USER INPUT n = int(input("Enter the position n to find the nth Lucas Number: ")) print(f"The {n}th Lucas Number is: {lucas_func(n)}") """ -THE OUTPUT:- +THE OUTPUT:- Enter the position n to find the nth Lucas Number: 6 The 6th Lucas Number is: 18 -""" \ No newline at end of file +""" diff --git a/maths/area.py b/maths/area.py index c95d076f2e49..648afd04bf18 100644 --- a/maths/area.py +++ b/maths/area.py @@ -270,17 +270,17 @@ def area_of_parabola(x,a,b,c): """ Area under the parabola y = 1x² + 0x + 0 from x = 0 to x = 2 is 2.666666666666667 """ - return a * x**2 + b * x + c + return a * x**2 + b * x + c def area_under_parabola(a, b, c, x1, x2): area, _ = quad(parabola, x1, x2, args=(a, b, c)) return area - #example usage + #example usage a = 1 - b = 0 + b = 0 c = 0 x1 = 0 - x2 = 2 + x2 = 2 area = area_under_parabola(a, b, c, x1, x2) print(f"Area under the parabola y = {a}x² + {b}x + {c} from x = {x1} to x = {x2} is {area}") From 76d3b7d9b8f4d0bca22b220ba860560b357ee3fd Mon Sep 17 00:00:00 2001 From: DEVANSH GAJJAR <162860692+DEVANSH-GAJJAR@users.noreply.github.com> Date: Sat, 21 Jun 2025 21:30:09 +0530 Subject: [PATCH 4/6] Add files via upload --- final_lucas_function.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 final_lucas_function.py diff --git a/final_lucas_function.py b/final_lucas_function.py new file mode 100644 index 000000000000..e69de29bb2d1 From 6ca442ecc498a247b1954d4ac0cf440d2fa9db96 Mon Sep 17 00:00:00 2001 From: DEVANSH GAJJAR <162860692+DEVANSH-GAJJAR@users.noreply.github.com> Date: Sat, 21 Jun 2025 21:31:00 +0530 Subject: [PATCH 5/6] Updated final_lucas_function.py --- final_lucas_function.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/final_lucas_function.py b/final_lucas_function.py index e69de29bb2d1..8077aab52664 100644 --- a/final_lucas_function.py +++ b/final_lucas_function.py @@ -0,0 +1,28 @@ +#Giving the output +def lucas_func(n): + #PREDFINING THE VALUES + a = 2 + b = 1 + + if n == 0: + return a + + # GENERATING THE NUMBER + for _ in range(2, n + 1): + c = a + b + a = b + b = c + + return b + +# USER INPUT +n = int(input("Enter the position n to find the nth Lucas Number: ")) +print(f"The {n}th Lucas Number is: {lucas_func(n)}") + +""" + +THE OUTPUT:- +Enter the position n to find the nth Lucas Number: 6 +The 6th Lucas Number is: 18 + +""" From a9fc330331c60dcc920dc5058fef44e324675b68 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 21 Jun 2025 16:04:27 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- final_lucas_function.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/final_lucas_function.py b/final_lucas_function.py index 8077aab52664..4bead62046b4 100644 --- a/final_lucas_function.py +++ b/final_lucas_function.py @@ -1,27 +1,28 @@ -#Giving the output +# Giving the output def lucas_func(n): - #PREDFINING THE VALUES + # PREDFINING THE VALUES a = 2 b = 1 - + if n == 0: return a - - # GENERATING THE NUMBER + + # GENERATING THE NUMBER for _ in range(2, n + 1): c = a + b a = b b = c - + return b - -# USER INPUT + + +# USER INPUT n = int(input("Enter the position n to find the nth Lucas Number: ")) print(f"The {n}th Lucas Number is: {lucas_func(n)}") """ -THE OUTPUT:- +THE OUTPUT:- Enter the position n to find the nth Lucas Number: 6 The 6th Lucas Number is: 18