Question: Pyhton please! 2 9 . 2 0 LAB: Swap two numbers Complete the swap ( ) method to exchange the values of the num attribute
Pyhton please! LAB: Swap two numbers
Complete the swap method to exchange the values of the num attribute of two Number objects, num and num
Hint: Refer to the given Number class to see the definitions of num attribute and other instance methods available.
Ex: If num is and num is calling swapnum num will swap the values so that num becomes and num becomes
class Number:
def initself n:
self.num n
def getnumself:
return self.num
def setnumself n:
self.num n
def swapnum num:
numnum self.num
numnum numnum
numnum numnum
if namemain:
int intinput
int intinput
num Numberint
num Numberint
swapnum num
printnumnumgetnum'and numnumgetnum
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
