forked from gauriiighadge/HactoberFest2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
swap.py
31 lines (20 loc) · 753 Bytes
/
swap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def swap_numbers(first_number, second_number):
"""
Swaps the values of two numbers.
Args:
first_number (float): The first number.
second_number (float): The second number.
Returns:
Tuple[float, float]: A tuple containing the swapped numbers.
"""
first_number, second_number = second_number, first_number
return first_number, second_number
try:
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
except ValueError:
print("Invalid input. Please enter valid numbers.")
exit(1)
print(f"Before swapping: num1 = {num1}, num2 = {num2}")
num1, num2 = swap_numbers(num1, num2)
print(f"After swapping: num1 = {num1}, num2 = {num2}")