Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python simple value function swap for intro to computer science class. Please help! I'm stuck. :( def swap_value(a, b): 04. Swapping values: does this
Python simple value function swap for intro to computer science class. Please help! I'm stuck. :( def swap_value(a, b): """ 04. Swapping values: does this work for the know data types? Finish this swap_values function. This function takes two arguments and swap their values. The input value, a and b may have same or different data types, including int, float, string or bool. This function does not have explicit return values. Hint: you may need a third variable to help you when swapping the values. Hint: you should find swapping values with a function call does not work. """ print("Add your solution here")
# tests for Q4 int_a = 2018 float_a = 10.50 swap_value(int_a, float_a) print("After calling swap_value function, int_a is {}, float_a is {}".format(int_a,float_a)) string_a = "hello world" swap_value(string_a, float_a) print("After calling swap_value function, string_a is {}, float_a is {}".format(string_a,float_a)) print("--"*20)
****I tried inserting:
temp_variable = a a = b b = temp_variable
under the print function, but it didn't work.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started