Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Object-Oriented Python Instant Objects Methods

What does the character import Theft work in the video? In the repl?

what does the word import means generally in python

1 Answer

Mel Rumsey
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Mel Rumsey
Treehouse Staff

Hi Hanwen Zhang!

Importing is when you are accessing a different python script or python module from your working python file. For example, If you are wanting to get a random number between 1 and 10, there is a python module that you can access called random which contains a randint() function. When you import random you are gaining access to everything that module contains. So when you call random.randint(1,10) that is accessing the random module, calling the randint() function, and passing in the required arguments.

What Kenneth is doing when importing random is he is also using the randint() function, but only for the numbers 0 and 1 because the integer 0 is falsy and 1 is truthy.

You can read up more on importing here! Hope this helps!

Thank you Mel