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 ..
I am trying to sort my dataframe values by datetime. However, I get an empty index/dataframe as an output: Here is an example- Init price date glov 1 01/01/2020 00:00:00 xxx 6 01/02/2020 00:00:00 glov 3 01/03/2020 00:00:00 xxx 4 01/04/2020 00:00:00 expected output: for a date selected from 01/01/2020 00:00:00 to 01/03/2020 00:00:00 – ..
I working on a project that is broken into multiple files, and while I know my issue is that I’m not initializing an instance of the class I’m trying to use, I can’t figure out where to do so. The two files are below – the DataLayer and the main file. The issue in question ..
I am working with objects, which have many attributes. I am not using all of the attributes but if I access one then I will use it many times. Is it possible to initialize an attribute only during the first time it gets accessed. I came up with the following code, which is sadly really ..
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 ..
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 ..
I am currently learning the basics of Object Oriented Programming in python. I’m trying to make a class that gets the students’ name, age, and grade. And a class named "course" that adds the students that are enrolled in a course, and I want to get the average grades of the students enrolled in a ..
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)) self.rows=[lst[i][:] for i in range(self.dim)] self.columns=[[lst[i][j] for i in range(self.dim)] for j ..
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 ..
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 ..