Repository: TheAlgorithms/Python

Issue:
simple_neural_network.py: Fewer forward propogations to speed tests
Closes #9718

### Describe your change:



* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
* [ ] Documentation change?

### Checklist:
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is all my own work -- I have not plagiarized.
* [x] I know that pull requests will not be merged if they fail the automated tests.
* [x] This PR only changes one algorithm file.  To ease review, please open separate PRs for separate algorithms.
* [ ] All new Python files are placed inside an existing directory.
* [ ] All filenames are in all lowercase characters with no spaces or dashes.
* [ ] All functions and variable names follow Python naming conventions.
* [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html).
* [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing.
* [ ] All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
* [ ] If this pull request resolves one or more open issues then the description above includes the issue number(s) with a [closing keyword](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue): "Fixes #ISSUE-NUMBER".



Discussion:

Resolving patch:
diff --git a/conversions/ipv4_conversion.py b/conversions/ipv4_conversion.py
new file mode 100644
--- /dev/null
+++ b/conversions/ipv4_conversion.py
@@ -0,0 +1,85 @@
+# https://www.geeksforgeeks.org/convert-ip-address-to-integer-and-vice-versa/
+
+
+def ipv4_to_decimal(ipv4_address: str) -> int:
+    """
+    Convert an IPv4 address to its decimal representation.
+
+    Args:
+        ip_address: A string representing an IPv4 address (e.g., "192.168.0.1").
+
+    Returns:
+        int: The decimal representation of the IP address.
+
+    >>> ipv4_to_decimal("192.168.0.1")
+    3232235521
+    >>> ipv4_to_decimal("10.0.0.255")
+    167772415
+    >>> ipv4_to_decimal("10.0.255")
+    Traceback (most recent call last):
+        ...
+    ValueError: Invalid IPv4 address format
+    >>> ipv4_to_decimal("10.0.0.256")
+    Traceback (most recent call last):
+        ...
+    ValueError: Invalid IPv4 octet 256
+    """
+
+    octets = [int(octet) for octet in ipv4_address.split(".")]
+    if len(octets) != 4:
+        raise ValueError("Invalid IPv4 address format")
+
+    decimal_ipv4 = 0
+    for octet in octets:
+        if not 0 <= octet <= 255:
+            raise ValueError(f"Invalid IPv4 octet {octet}")  # noqa: EM102
+        decimal_ipv4 = (decimal_ipv4 << 8) + int(octet)
+
+    return decimal_ipv4
+
+
+def alt_ipv4_to_decimal(ipv4_address: str) -> int:
+    """
+    >>> alt_ipv4_to_decimal("192.168.0.1")
+    3232235521
+    >>> alt_ipv4_to_decimal("10.0.0.255")
+    167772415
+    """
+    return int("0x" + "".join(f"{int(i):02x}" for i in ipv4_address.split(".")), 16)
+
+
+def decimal_to_ipv4(decimal_ipv4: int) -> str:
+    """
+    Convert a decimal representation of an IP address to its IPv4 format.
+
+    Args:
+        decimal_ipv4: An integer representing the decimal IP address.
+
+    Returns:
+        The IPv4 representation of the decimal IP address.
+
+    >>> decimal_to_ipv4(3232235521)
+    '192.168.0.1'
+    >>> decimal_to_ipv4(167772415)
+    '10.0.0.255'
+    >>> decimal_to_ipv4(-1)
+    Traceback (most recent call last):
+        ...
+    ValueError: Invalid decimal IPv4 address
+    """
+
+    if not (0 <= decimal_ipv4 <= 4294967295):
+        raise ValueError("Invalid decimal IPv4 address")
+
+    ip_parts = []
+    for _ in range(4):
+        ip_parts.append(str(decimal_ipv4 & 255))
+        decimal_ipv4 >>= 8
+
+    return ".".join(reversed(ip_parts))
+
+
+if __name__ == "__main__":
+    import doctest
+
+    doctest.testmod()
diff --git a/neural_network/simple_neural_network.py b/neural_network/simple_neural_network.py
--- a/neural_network/simple_neural_network.py
+++ b/neural_network/simple_neural_network.py
@@ -28,7 +28,7 @@ def sigmoid_function(value: float, deriv: bool = False) -> float:
 def forward_propagation(expected: int, number_propagations: int) -> float:
     """Return the value found after the forward propagation training.
 
-    >>> res = forward_propagation(32, 10000000)
+    >>> res = forward_propagation(32, 450_000)  # Was 10_000_000
     >>> res > 31 and res < 33
     True
 


Test patch: