Skip to content
Advertisement

Tag: oop

EXP system for adjusting instance attributes in Python (text-based RPG)

I have recently begun programming in Python and decided to start my journey by writing a text-based RPG. The issue that I have now stumbled upon is that I was trying to create an EXP-system to make the character’s stats dependent on their level, but it doesn’t seem to work the way I want it to. While I have achieved

Kivy Python: confused with class and instance methods

I was trying kivy and while I was accessing class variables, I was forced to use ‘self’ for class variables or else it was producing error. This is the kivy code I was using. Below is the main.py code where I have confusion: This code works. Here I am using class variables and accessing them from ‘self’. According to me

Segmentation fault in destructor with Python

I have made a class to represent my led strip, and I would like to switch off the strip when I stop it (aka when the program stops and the object is destroyed). Hence, as I would do in C++, I created a destructor to do that. But it looks like Python call it after it destroyed the object. Then

Making child class inherit methods from parent in tkinter

I’m new to Tkinter and OOP. I’ve been trying to make child class inherit some methods from parent class because I’d have repeated code if I didn’t do it like that. But I’ve stumbled on a problem, caused probably by my limited knowledge of Tkinter and OOP. Here is my code: (it’s really simplified, but it is enough to solve

GCD implementation of fraction addition not working properly

I am following the Runestone Academy Python3 course and tried to implement ‘addition’ feature for fractions using Class but I am getting error. When I am not using GCD implementation, the code is running fine Here is my code: This is the error I am getting: I also tried with this variation but same error: Answer The gcd method should

Advertisement