Class 12th CBSE CS
Write a function SwapNumbers( ) to swap two numbers and display the numbers before swapping and after swapping.
Solution: –
def SwapNumbers(a, b): print("Before swapping: a =", a, ", b =", b) a, b = b, a # This is the Pythonic way to swap variables print("After swapping: a =", a, ", b =", b) # Example usage: num1 = 10 num2 = 20 SwapNumbers(num1, num2)
Fun & Easy to follow
Works on all devices
Your own Pace
Super Affordable
Popular Videos
UX for Teams
Learn the basics and a bit beyond to improve your backend dev skills.

Chris Matthews
Designer
SEO & Instagram
Learn the basics and a bit beyond to improve your backend dev skills.

Chris Matthews
Designer