• Free Template
  • Web Dev
    • CSS
    • PHP Scripting
    • HTML 5
    • Articles
  • Programming
    • Python
    • C++
    • Java
    • C Programming
    • Data Structure
    • Articles
  • Tips & Tricks
  • Technology
  • What's Hot
  • Subscribe Us

python Examples

  • Introduction
  • Hello World
  • Arithmetic Operations
  • Multiplication Table
  • Compare Variables
  • Prime Number
  • Armstrong Number
  • Factorial
  • Leap Year
  • Recursive Factorial
  • Fibonacci Series
  • 1's Complement
  • ASCII Conversion
  • Palindrome Number
  • Palindrome String
  • Matrix Addition
  • Matrix Multiplication
  • Remove Vowel
  • Class Object
  • Inheritance
  • Multiple Inheritance
  • Multilevel Inheritance
  • Polymorphism
  • Dictionary
  • List Data Structure
  • Swapping values
  • Star Pyramid
  • Directory
  • File Operation
  • Delete file & directory
  • Bubble Sort
  • Insertion Sort
  • Selection Sort
  • Quick Sort
  • Merge Sort
  • Heap Sort

Aug 9, 2021

Swapping values

Python Programming 2342 views
#!/usr/bin/evn python

a = 5
b = 8

print ('Before swap')
print(a, b)

# Tuples: swaps values
a, b = b, a

print ('After swap')
print(a, b)


# ***** Output *****
Before swap
5 8
After swap
8 5

Tuples

Tags:
pythonpython programmingswapping valuespython tuples
Author: Geekboots
Share On
Geekboots © 2022 About UsContact UsTermsCookie PolicyPrivacySubmit Article