0% found this document useful (0 votes)
666 views

5.18 LAB Swapping Variables

Uploaded by

Kevin Nyasogo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
666 views

5.18 LAB Swapping Variables

Uploaded by

Kevin Nyasogo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

5.

18 LAB: Swapping variables


10/10
Write a program whose input is two integers and whose output is the two integers
swapped.
Ex: If the input is:
38

the output is:


8 3

Your program must define and call the following function. swap_values() returns the
two values in swapped order.
def swap_values(user_val1, user_val2)

def swap_values(user_val1, user_val2):

temp = user_val1

user_val1 = user_val2

user_val2 = temp

This study source was downloaded by 100000864675654 from CourseHero.com on 03-31-2023 16:02:33 GMT -05:00

https://www.coursehero.com/file/95745528/518-LAB-Swapping-variablesdocx/
return user_val1, user_val2

if __name__ == '__main__':

user_val1 = int(input())

user_val2 = int(input())

print(user_val2, user_val1)

This study source was downloaded by 100000864675654 from CourseHero.com on 03-31-2023 16:02:33 GMT -05:00

https://www.coursehero.com/file/95745528/518-LAB-Swapping-variablesdocx/
Powered by TCPDF (www.tcpdf.org)

You might also like