Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #General Features about computers
- class Computer:
- def __init__(self, model, cpu, ram, storage, os):
- self.model = model
- self.cpu = cpu
- self.ram = ram
- self.storage = storage
- self.os = os
- #Function that tell the features line by line
- def tell(self):
- print("Name: {}\nCPU: {}\nRam: {}\nStorage: {}\nOS: {}".format(self.model, self.cpu, self.ram, self.storage, self.os))
- #Further features about laptops
- class Laptop(Computer):
- def __init__(self, model, cpu, ram, storage, os):
- Computer.__init__(self, model, cpu, ram, storage, os)
- self.weight = 'default'
- self.size = 'default'
- #Function that tell the features line by line
- def tell(self):
- Computer.tell(self)
- print("Weight: {}\nSize: {}\n".format(self.weight, self.size))
- computer1 = Laptop(input("Enter the Model:"), input("Enter the Cpu:"), input("Enter the ram:"), input("Enter the Storage:"), input("Enter the OS:"))
- #computer1.cpu = 'Intel Core i5 3Ghz Quad'
- #computer1.ram = "8 GB"
- #computer1.storage = '250 GB SSD'
- #computer1.os = 'Mac OS X High Sierra'
- #computer1.weight = '1.67 KG'
- #computer1.size = '13 INCH'
- computer1.weight = input("Enter the weight:")
- computer1.size = input("Enter the size:")
- print()
- computer1.tell()
Add Comment
Please, Sign In to add comment