0

I'm taking a course on Coursera and doing an assignment after watching a teaching video. enter image description here

enter image description here

I wanna know why it shows "NameError: name 'histogram' is not defined" after running my own code.

8
  • histogram() is not a built-in function, you need to define it. Commented May 27, 2020 at 17:47
  • How to define it? I know maybe it's a silly question but I never learned Python so don't know how to do that? Commented May 27, 2020 at 17:50
  • The video probably included the definition earlier. Commented May 27, 2020 at 17:52
  • Oh actually no. Commented May 27, 2020 at 17:53
  • Or maybe it's in a library that you're supposed to download. I would expect the course to explain how to get the definition. Commented May 27, 2020 at 17:53

2 Answers 2

1

Add histogram library in your code. please add line in the starting of the code. I should work properly.

from histograms import histograms 
Sign up to request clarification or add additional context in comments.

Comments

1

You'll need to import the Histogram function as it is not built into Python. There are a few different packages that offer histograms -- for example pyplot and numpy. Here's an example using numpy

import numpy as np np.histogram([1, 2]) 

Documentation: https://numpy.org/doc/1.18/reference/generated/numpy.histogram.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.