Created
March 19, 2019 11:35
-
-
Save coder-shanks/2432dc5026d9d17afddfd5415b0fc75d to your computer and use it in GitHub Desktop.
Swap the two numbers using a third variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first_number = 5 | |
second_number = 7 | |
# Storing the value of first number in a temporary variable | |
temp = first_number # temp = 5 | |
# Replacing the value of first_number by second_number | |
first_number = second_number # first_number = 7 | |
# Assigning the cached value of first number in temp variable | |
# to second_number | |
second_number = temp # second_number = 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Swap the two numbers using a third variable