Absolute Imports In Packages
Mon 10 August 2026
from my_package.analytics.stats import calculate_mean
Score: 5
Category: chapter10_modules_and_packages
from my_package.analytics.stats import calculate_mean
Score: 5
Category: chapter10_modules_and_packages
import datetime
today = datetime.date.today()
print(today)
2026-01-14
Score: 10
Category: chapter10_modules_and_packages
Read More# my_package/module1.py
def greet():
return "Hello from module1"
# main.py
import my_package.module1
print(my_package.module1.greet())
Score: 10
Category: chapter10_modules_and_packages
Read More# file: calculator.py
def multiply(a, b):
return a * b
# main.py
import calculator
print(calculator.multiply(4, 5)) # Output: 20
Score: 10
Category: chapter10_modules_and_packages
Read Moreimport math
print(dir(math))
['__doc__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'cbrt', 'ceil', 'comb', 'copysign', 'cos', 'cosh', 'degrees', 'dist', 'e', 'erf', 'erfc', 'exp', 'exp2', 'expm1', 'fabs', 'factorial', 'floor', 'fma', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'isqrt', 'lcm', 'ldexp', 'lgamma …Category: chapter10_modules_and_packages
Read Moreimport math
print(math.sqrt(25)) # Output: 5.0
5.0
Score: 10
Category: chapter10_modules_and_packages
Read Morefrom my_package.module1 import greet
print(greet())
Score: 5
Category: chapter10_modules_and_packages
Read Morefrom math import sqrt, pow
print(sqrt(16)) # Output: 4.0
print(pow(2, 3)) # Output: 8.0
4.0
8.0
Score: 10
Category: chapter10_modules_and_packages
Read Moreimport sys
print(sys.path)
['C:\\Users\\Ashwin\\AppData\\Local\\Programs\\Python\\Python313\\python313.zip', 'C:\\Users\\Ashwin\\AppData\\Local\\Programs\\Python\\Python313\\DLLs', 'C:\\Users\\Ashwin\\AppData\\Local\\Programs\\Python\\Python313\\Lib', 'C:\\Users\\Ashwin\\AppData\\Local\\Programs\\Python\\Python313', '', 'C:\\Users\\Ashwin\\AppData\\Local\\Programs\\Python\\Python313\\Lib …Category: chapter10_modules_and_packages
Read Morepip install requests
import requests
response = requests.get("https://api.example.com")
print(response.status_code)
Score: 15
Category: chapter10_modules_and_packages
Read More