SimeonTs

SUPyF2 D.Types and Vars More Exercises - 02. Exchange Intege

Sep 27th, 2019
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. """
  2. Data Types and Variables - More Exercises
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1723#1
  4.  
  5. SUPyF2 D.Types and Vars More Exercises - 02. Exchange Integers
  6.  
  7. Problem:
  8. Read two integer numbers and after that exchange their values by using some programming logic.
  9. Print the variable values before and after the exchange, as shown below:
  10.  
  11. Examples:
  12. Input
  13. 5
  14. 10
  15. Output:
  16. Before:
  17. a = 5
  18. b = 10
  19. After:
  20. a = 10
  21. b = 5
  22. You may use a temporary variable to remember the old value of a, then assign the value of b to a,
  23. then assign the value of the temporary variable to b.
  24. """
  25. a = int(input())
  26. b = int(input())
  27. print(f"Before:\na = {a}\nb = {b}")
  28. c = a
  29. a = b
  30. b = c
  31. print(f"After:\na = {a}\nb = {b}")
Add Comment
Please, Sign In to add comment