MCPcopy Create free account
hub / github.com/geekcomputers/Python / __init__

Method __init__

swap.py:18–34  ·  view source on GitHub ↗

Initialize the Swapper class with two values. Parameters: ---------- x : int The first value to be swapped. y : int The second value to be swapped.

(self, x, y)

Source from the content-addressed store, hash-verified

16 """
17
18 def __init__(self, x, y):
19 """
20 Initialize the Swapper class with two values.
21
22 Parameters:
23 ----------
24 x : int
25 The first value to be swapped.
26 y : int
27 The second value to be swapped.
28
29 """
30 if not isinstance(x, (int, float)) or not isinstance(y, (float, int)):
31 raise ValueError("Both x and y should be integers.")
32
33 self.x = x
34 self.y = y
35
36 def display_values(self, message):
37 print(f"{message} x: {self.x}, y: {self.y}")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected