9p


This is for Python I need help.
Note : I will develop the Person , Student ,faculty and will uypdate ...thank u
=======================================
#Pet.py (Pet class)
class Pet:
def __init__(self,name,age):
self.mName=name
self.mAge=age
def getName(self):
return self.mName
def getAge(self):
return self.mAge
===================================
# Dog.py (Dog class)
import Pet
class Dog(Pet.Pet):
def __init__(self,name,age,size):
Pet.Pet.__init__(self,name,age)
self.mSize=size
def getSize(self):
return self.mSize
def momComment(self):
if self.mSize=="small":
return "ankle biter"
elif self.mSize=="med":
return "great"
else :
return "barking mad"
def getDogYears(self):
y=0
for i in range(self.getAge()):
y+=7
return y
=========================================
#Cat.py (Cat class)
import Pet
class Cat(Pet.Pet):
def __init__(self,name,age,color):
Pet.Pet.__init__(self,name,age)
self.mColor=color
def getColor(self):
return self.mColor
def prettyFactor(self):
if self.mColor in ["calico","white","tuxedo"]:
return "puuuurfect"
else :
return "boring"
def getCatYears(self):
y=0
for i in range(self.getAge()):
if i<2 :
y+=25
else :
y+=4
return y
============================================
import Dog
from Cat import Cat
p1=Dog.Dog("Prince",11,"med")
print(p1.getName()+" is "+p1.momComment())
print(str(p1.getAge())+" = "+str(p1.getDogYears()))
p2=Cat("Fluffy",10,"brown")
print(p2.getName(),"is",p2.prettyFactor())
print(p2.getAge(),"=",p2.getCatYears())
=========================================
Output:

========================================
9p This is for Python I need help. Pet #pet.py mName mAge class Pet: + __init__(name,...
10q
I need help this is a python language
For the following question, refer to the Python module on the right, as well as the name of the file that contains each module. 1) What is the output of the following code?. import animals alist = [animals.cat('Garfield'), animals.Dog('odie'), animals. Fox ('Nicholas P. wilde'), animals. Animal ('Judy Hopps')] File animals.py class Animal: def _init__(self, name): self.name = name def getName(self): return self.name for a in alist: print( a.getName() + ', '...
9c
Python
1) What is the output of the following code? Refer to the Weapon, Blaster, and Bowcaster classes. File 1: weapon.py class Weapon: def init ( self, power ): self.mPower = power return Example: import blaster from bowcaster import Bowcaster def getPower( self ): return self.mPower han = blaster.Blaster( 8000, 20 ) print("HP:", han.getPower( ) ) print( "HR:", han.getFireRate()) chewie = Bowcaster( 3000, 6) print( "CB:", chewie.getBarrelSize()) print( "CR:", chewie.getRange()) File 2: blaster.py import weapon class Blaster( weapon. Weapon):...
Need help finishing this code # Description : The Pet class contains fields for name, pet # type,and age. The age field is the age now # or age of pet when it passed away. (These # are all dogs I have had.) There is a static or # class variable called number_pets that # tracks how many instances have been created. # The constructor will fill all fields and add # one to the number_pets variable. # The special...
10p
Python
For the following question, refer to the Python module on the right, as well as the code below. 1) What is the output of the following code? #dodgeable.py #main dodgeable.py import dodgeable class Locatable: def NUM_CARS = 3 init (self,x,y): NUM TRUCKS = 2 self.mX = X WIDTH = 60 self.mY = y def setx (self,x): def main (): self.mX = x object_list = [] def sety (self, y): self.mY = y for i in range (NUM_CARS) :...
USE PYTHON CODING ####################### ## ## Definition for the class Pet ## ######################## class Pet: owner="" name="" alive=False def __init__(self,new_name): self.name=new_name self.alive=True Using the code shown above as a base write a code to do the following: - Create a separate function (not part of the class) called sameOwner which reports whether two pets have the same owner. test it to be sure it works - Add a variable age to Pet() and assign a random value between 1 and...
11) What ten values would be printed if the following code was run? write your answer in the correct order 11a to 11j class Pat(): def__init__(self, name, age): self._name = name self._age = age def __str__(self): return "Pet: +self._name+ " "+str(self._age) def getName(self): return self._name def getAge(self): return self._age def setName(self,newName): self._age =newAge def incrementAge(self): self._age = self._age +1 pet1 = Pet ("Fluffy" ,5) pet2 = Pet ("Spot", 2) print (pet1) print (Pet.__doc__) pet2.setName("Dot") print(pet2.getAge()) pet1.incrementAge() print(pet1.getAge()) pet2.setAge(4) print(Pet.getName.__doc__) f...
Python only please, thanks in advance.
Type up the GeometricObject class (code given on the back of the paper). Name this file GeometricObjectClass and store it in the folder you made (xxlab14) 1. Design a class named Rectangle as a subclass of the GeometricObject class. Name the file RectangleClass and place it in the folder. 2. The Rectangle class contains Two float data fields named length and width A constructor that creates a rectangle with the specified fields with default...
Consider following flower class. class Flower: def __init__(self, Fname, numberofpetals, Fprice): self.Fname = Fname self.numberofpetals = numberofpetals self.Fprice = Fprice def getName(self): return self.Fname def getPetalsCount(self): return self.numberofpetals def getPrice(self): return self.Fprice def setName(self, Fname): self.Fname = Fname def setPetalsCount(self, numberofpetals): self.numberofpetals = numberofpetals def setPrice(self, Fprice): self.Fprice = Fprice def main(): flower f, print("name = ", flower.getName()) flower.setName("jasmine") print("name = ", flower.getName()) main() Q. What is the statement to set an object flower with rose , 4 and price...
Python only please, thanks in advance.
Type up the GeometricObject class (code given on the back of the paper). Name this file GeometricObjectClass and store it in the folder you made (xxlab14) 1. Design a class named Rectangle as a subclass of the GeometricObject class. Name the file RectangleClass and place it in the folder. 2. The Rectangle class contains Two float data fields named length and width A constructor that creates a rectangle with the specified fields with default...
PYTHON 3.8 class student(): def __init__(self, name = 'Bill', grade = 9, subjects = ['math','science']): self.name = name self.grade = grade self.subjects = subjects def add_subjects(self): print('Current subjects:') print(self.subjects) more_subjects = True while more_subjects == True: subject_input = input('Enter a subject to add: ') if subject_input == '': more_subjects = False print(self.subjects) else: self.subjects.append(subject_input) print(self.subjects) m = student()...