PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Python · Theory

Python Modules

← All stacks

Theory

46/268

Python Modules

A module is a .py file you import and reuse. import math then math.sqrt(9) is 3.0. from math import sqrt lets you call sqrt(9) directly. Your own utils.py can be a module if it sits on the path. A package is a folder of modules (often with __init__.py).

import math brings the whole module namespace. from math import sqrt brings one name. If two modules have sqrt, import module keeps them apart: math.sqrt vs other.sqrt. Don’t star-import in real code.

Python Modules — output — 7.0 then 3.14159…. math is a real stdlib module.

Exam tip

import vs from-import difference.

Example

# Modules
import math
print(math.sqrt(49))
print(math.pi)

Python Modules — output: 7.0 then 3.14159…. math is a real stdlib module.

Short notes

  • Def.py file you import.
  • Ruleimport x vs from x import y.
  • RememberYour file can be a module.

Questions

1

Explain Modules as if you are teaching a junior — definition, then one tiny script.

2

What does the example print, and why?

3

What mistake do freshers make with Modules?

Previous← def Function in PythonNextList Comprehension in Python →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.