A common mistake that can come up when using modules and libraries is not importing them first. In this video, learn how to recognize errors that result from this mistake and avoid this mistake.
- [Instructor] A common mistake that can come up … when using modules in libraries in your code … is not importing them first. … For example, let's say … that I want to take the square root of a number. … So I call the SQRT function … from Python's math library like this. … As you can see, when I ran the cell, … I got a name error that says name math is not defined. … This is because I did not import the math library … before referring to its SQRT function. … To fix this, I can add a cell above in which I import math. … As you can see, when I rerun the cells … everything worked and there were no errors. … So make sure you remember … to import all relevant libraries and modules first … before you try to access specific functions from them. … …
Skill Level Intermediate
1. Avoid Mistakes in Coding Practices
2. Avoid Mistakes in Structuring Code
3. Avoid Mistakes in Handling Data
4. Avoid Mistakes in Machine Learning
Using redundant features1m 45s
Get started with Python1m 7s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.