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

Which sample distribution is most likely to be from this population distribution?
Use the distributive property to find 8x22
Which sentence is punctuated correctly? A In the yard, he saw cardinals robins and a squirrel. B. In the yard he saw cardinals, robins, and a squirrel. C. In t
Biochemical Evidence-definition
how did Job's interest in calligraphy in college benefit him professionally later on ?
Law of sines: startfraction sine (uppercase a) over a endfraction = startfraction sine (uppercase b) over b endfraction = startfraction sine (uppercase c) over
True or False In addition to earth, many of the other planets in the solar system have atmospheres.
What is the national sorry day!
1. ¿Qué está esperando Julio? 2. ¿Qué espera ver escrito en esa lista? 3. ¿Cuál es la posición en el equipo que Julio desearía tener? 4. ¿Qué quiere lograr Juli
What is the answer ?