nameerror

How to fix NameError: name 'colors' is not defined

How to fix NameError: name 'colors' is not defined Question: Trying to plot this code but encountering this error and unable to find resolution of correcting: df = pd.read_csv("./train.csv") # Bar plot for exercise induced angina by heart disease. # Y: Yes, N: No fig, ax=plt.subplots(1, 3, figsize=(14, 5), sharey=True) l = [‘index’, ‘exercise angina’] …

Total answers: 1

NameError: name 'Class_Name' is not defined

NameError: name 'Class_Name' is not defined Question: I have an issue which is I keep getting the error of NameError: name ‘Class_Name’ is not defined. Which I understand. The tricky part is that my code looks something like this: class FirstClass(): second_class: SecondClass def __init__(self): """SOME CODE HERE""" class SecondClass(firsClass: FirstClass): def __init__(self): self.first_class = …

Total answers: 2

NameError: name 'rank' is not defined even though i have mentioned it in global

NameError: name 'rank' is not defined even though i have mentioned it in global Question: The code below is a simplified version of a bigger code. The main action i want to perform is to use and change rank and progress inside the inc_progress(self) function. class User: rank=-8 progress=0 def inc_progress(self): global rank, progress rank+=1 …

Total answers: 1

How do I define an empty python list and append values, without the NameError?

How do I define an empty python list and append values, without the NameError? Question: I am trying to create and print a deck of cards and the following error is displayed Traceback (most recent call last): File "/Users/file/file/file/main.py", line 11, in <module> print(deck) NameError: name ‘deck’ is not defined I have tried replacing the …

Total answers: 4

Checking if an object is in a determined class python

Checking if an object is in a determined class python Question: I’m trying to create a class representing vectors (called Vector) and one representing matrices (called Matrix). The problem arised in defining the matrix-vector product: I don’t see errors in the actual implementation, but I tried to add a check before the code to raise …

Total answers: 1

does anyone know why my width is not defined, it seems that i have

does anyone know why my width is not defined, it seems that i have Question: from tkinter import * import random root=Tk() root.geometry("400×400") canvas = Canvas(root,width= width,height= height, bg=’black’) canvas.pack(pady=20) width,height=200,200 shape=canvas.create_circle(fill=yellow) def pressed(event): index=random.randrange(0,5) x,y=0,0 if event.char == "a": x,y =-10,0 if event.char == "d": x,y =10,0w if event.char == "w": x,y =0,-10 if …

Total answers: 1

How can define a new parameter in function and later use it?

How can define a new parameter in function and later use it? Question: I get the error: "AttributeError: ‘function’ object has no attribute ‘request_symbol’" when running my code. Can somebody explain how can i define new parameter in def and then later use it? def request_income_statement (symbol, api_key): url = ‘https://www.alphavantage.co/query?function=INCOME_STATEMENT&symbol=’ + symbol + ‘&apikey=’ …

Total answers: 2

What am I not understanding about 'self' instance?

What am I not understanding about 'self' instance? Question: Here is a link to my github: airplane.py I keep receiving the error: NameError: name ‘self’ is not defined I have looked through countless other stack overflow threads and there is clearly something I am not understanding about the self instance, because it feels like I’ve …

Total answers: 2

NameError: name '__file__' is not defined

NameError: name '__file__' is not defined Question: I am trying to store the path of a script into a variable using: os.path.abspath(os.path.dirname(__file__)) However, it keeps returning a name ‘__file__’ is not defined error. here = os.path.dirname(os.path.abspath(__file__)) Traceback (most recent call last): File “<stdin>”, line 1, in <module> NameError: name ‘__file__’ is not defined Asked By: …

Total answers: 2