nachy4995 nachy4995
  • 18-07-2020
  • Computers and Technology
contestada

Define a function named swap_nums that has 2 parameters: num_one and num_two. The function should swap the two numbers by using only one additional variable!

Respuesta :

frknkrtrn
frknkrtrn frknkrtrn
  • 21-07-2020

Answer:

def swap_nums(num_one, num_two):

   temp_value = num_one

   num_one = num_two

   num_two = temp_value

   

   return num_one, num_two

print(swap_nums(10, 20))

Explanation:

Create a function called swap_nums that takes num_one and num_two as parameters.

Inside the function, create a temporary variable, temp_value, and set it to the num_one. Set the num_one as num_two and num_two as temp_value. Return the num_one and num_two

Call the function with two numbers and print the result

Answer Link

Otras preguntas

Give one argument in favor of the Tea Act and one argument against the Tea Act.
Which leader of the Scientific Revolution in France developed the mathematical system of Cartesian coordinates? A. René Descartes B. Francis Bacon C. Nicholas C
for the love of God help me !! I'm desperate for it tomorrow
PLEASE HELPP ME Solve the inequality | f | > 4.
What is the value of x?
How does the steepness of the concentration gradient influence the rate of transport?
A narrow channel or slab of a mineral that is different from the surrounding rock is called a_______
Is the Haystack Rock made of continental crust or oceanic crust?
Jamie has a job paying $25,000 and expects to receive a $1000 raise each year. Wei has a job paying $19,000 a year and expects a $1500 raise each year. For wha
Turn the equation into factored form Y=x^3+3x^3-6x-8