The document describes an experiment to write a program that swaps two numbers using functions. It outlines defining a swap function that gets two numbers as input, stores the first in a temporary variable, assigns the second number to the first, and assigns the temporary variable to the second number, effectively swapping the values. The program is executed successfully and outputs the swapped values, demonstrating how to use functions to swap numbers in Python.
The document describes an experiment to write a program that swaps two numbers using functions. It outlines defining a swap function that gets two numbers as input, stores the first in a temporary variable, assigns the second number to the first, and assigns the temporary variable to the second number, effectively swapping the values. The program is executed successfully and outputs the swapped values, demonstrating how to use functions to swap numbers in Python.
The document describes an experiment to write a program that swaps two numbers using functions. It outlines defining a swap function that gets two numbers as input, stores the first in a temporary variable, assigns the second number to the first, and assigns the temporary variable to the second number, effectively swapping the values. The program is executed successfully and outputs the swapped values, demonstrating how to use functions to swap numbers in Python.
Aim: Write a program to swap Two Numbers using functions.
Objective: ● To study the basics of python programming. Outcome: Students will be able to implement the basics of python programming. Algorithm\Implementation Steps\Installation Steps: 1. Define a function swap and call the function. 2. Get the first number 3. Get the second number 4. Print the numbers before swapping 5. Assign the first number with temporary variable ‘temp’ 6. Store the second number to the first number 7. Reassign the second number to the temporary variable 8. Print the Swapped values.
Source Code: Input and Output:
Conclusion: Thus the Python programs to exchange the values between two variables are executed successfully and the output is verified.