For python please Determine what each of these code fragment

For python please.

Determine what each of these code fragments does by reviewing the class definitions and mentally tracing the code snippets. Describe the value of x at the end of each assume they run in order.

Solution

class Mutant:
   def __init__(self):
       self.identity=\"\"
       self.powers=[]

   def get_id(self):
       return self.identity

   def set_id(self,x):

       self.identity=x

   def get_powers(self):
       return self.powers

   def set_powers(self,x):
       self.powers=x


wolverine=Mutant()
wolverine.set_id(\"Jimmy Hudson\")
wolverine.set_powers([\"Healing Factor\",\"Retractable Bone Claws\",\"Enhanced Senses\"])


cyclops=Mutant()
cyclops.set_id(\"Scott Summers\")
cyclops.set_powers([\"Projects concussive force from his eyes\"])

gambit=Mutant()
gambit.set_id(\"Remy LeBeau\")
gambit.set_powers([\"Explosive Kinetic Engery\",\"Enhanced Agility\",\"Hypnotic Charm\"])

#problem 7
x=gambit.get_powers().sort()
print x


#problem 8
storm=Mutant()
storm.set_id(\"Ororo Monroe\")
storm.set_powers(\"Weather Manipulation\")
x=storm.get_powers()[0]
print x

#problem 9
x=gambit.get_id()
print x

#problem 10
wolverine.set_id(\"Hugh Jackman\")
x=wolverine.get_id()
print x

#Problem 11
x=isinstance(wolverine,Mutant)
print x

#problem 12
x=\"gambit is wolverine\"
print x

=====================================

output:

None
W
Remy LeBeau
Hugh Jackman
True
gambit is wolverine

For python please. Determine what each of these code fragments does by reviewing the class definitions and mentally tracing the code snippets. Describe the valu
For python please. Determine what each of these code fragments does by reviewing the class definitions and mentally tracing the code snippets. Describe the valu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site