mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 17:34:49 +08:00
Pyupgrade to Python 3.9 (#4718)
* Pyupgrade to Python 3.9 * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -1,14 +1,14 @@
|
||||
"""
|
||||
Checks if a system of forces is in static equilibrium.
|
||||
"""
|
||||
from typing import List
|
||||
from __future__ import annotations
|
||||
|
||||
from numpy import array, cos, cross, ndarray, radians, sin
|
||||
|
||||
|
||||
def polar_force(
|
||||
magnitude: float, angle: float, radian_mode: bool = False
|
||||
) -> List[float]:
|
||||
) -> list[float]:
|
||||
"""
|
||||
Resolves force along rectangular components.
|
||||
(force, angle) => (force_x, force_y)
|
||||
|
@ -3,12 +3,12 @@
|
||||
Reference:
|
||||
- https://en.wikipedia.org/wiki/LU_decomposition
|
||||
"""
|
||||
from typing import Tuple
|
||||
from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
def lower_upper_decomposition(table: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
|
||||
def lower_upper_decomposition(table: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
|
||||
"""Lower-Upper (LU) Decomposition
|
||||
|
||||
Example:
|
||||
|
@ -1,7 +1,7 @@
|
||||
# https://www.geeksforgeeks.org/newton-forward-backward-interpolation/
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
from typing import List
|
||||
|
||||
|
||||
# for calculating u value
|
||||
@ -22,7 +22,7 @@ def ucal(u: float, p: int) -> float:
|
||||
|
||||
def main() -> None:
|
||||
n = int(input("enter the numbers of values: "))
|
||||
y: List[List[float]] = []
|
||||
y: list[list[float]] = []
|
||||
for i in range(n):
|
||||
y.append([])
|
||||
for i in range(n):
|
||||
|
@ -2,15 +2,16 @@
|
||||
# Author: Syed Haseeb Shah (github.com/QuantumNovice)
|
||||
# The Newton-Raphson method (also known as Newton's method) is a way to
|
||||
# quickly find a good approximation for the root of a real-valued function
|
||||
from __future__ import annotations
|
||||
|
||||
from decimal import Decimal
|
||||
from math import * # noqa: F401, F403
|
||||
from typing import Union
|
||||
|
||||
from sympy import diff
|
||||
|
||||
|
||||
def newton_raphson(
|
||||
func: str, a: Union[float, Decimal], precision: float = 10 ** -10
|
||||
func: str, a: float | Decimal, precision: float = 10 ** -10
|
||||
) -> float:
|
||||
"""Finds root from the point 'a' onwards by Newton-Raphson method
|
||||
>>> newton_raphson("sin(x)", 2)
|
||||
|
Reference in New Issue
Block a user