Category : oop

I’ve tried this: class Node: def __init__(self, initdata): self.data = initdata self.next = None class LinkedList: def __init__(self): self.head = None self.tail = None def add(self, data): new_node = Node(data) if self.head == None: self.head = new_node if self.tail != None: self.tail.next = new_node self.tail = new_node def reverseList(self): if self.head == None or self.head.next ..

Read more

Assume that the class Vehicle in Q.1 is already written in Python. Write code in Python with using inheritance for implementation of 02 child classes Car(NumberOfSeats) and MotorBike(SeatSize). In main code, create 05 objects of both Car and MotorBike classes, input their data, and serialize these objects to a binary file "Vehicles.bin". Read data from ..

Read more

I am venturing into python and wondering what one should look for to make a choice whether to use Object Oriented Programming paradigm or to remain on procedural paradigm. I developed a small program that looks for duplicate media files in two hard drives and delete the duplicates ones in the send drive. Would it ..

Read more

I’m new to here and I’m not really good at English so I apologize for probable future mistakes. My teacher asked us to write this program with classification… Here is the code class Matrix: def __init__(self,lst): self.mat = lst self.dim = (len(lst), len(lst[0])) self.rows=[lst[i][:] for i in range(self.dim[0])] self.columns=[[lst[i][j] for i in range(self.dim[0])] for j ..

Read more

I am new to Python and trying to get my head around Python OOP. I can see that using separate getter and setter is a bad approach and becomes tedious when there are a large amount of user accessible properties. The "proper" way to do this in Python therefore is to use @property and @propertyname.setter ..

Read more

I’m making this program to count the total price of items at a hypothetical store, and at the end I experience a double call. What is the best way to avoid this double call? (My grade kinda depends on this, pls help lol) #!/usr/bin/env python3 #Lukas Robin #07.06.2021 class Stonk: def __init__(self, name =”, price ..

Read more