# Modular Programming and Modules
"""
Packages
Modules
Function
"""
# Importing Modules
import math
math.sqrt ( 16 )
math.log ( 16, 2 )
math.cos ( 0 )
math.isnan(90)
import math
x=float('nan')
math.isnan(x)
math.acosh(45)
# Renaming a Namespace
#How to use package Aliasing in python
import math as MT
MT.sqrt ( 16 )
MT.log ( 16, 2 )
MT.cos ( 0 )
# Importing Names from a Module Directly
#How to use specific functions from packages or modules in python
from math import sqrt
sqrt ( 16 )
#How to use specific functions from packages or modules
#and also aliasing
from math import sqrt as square
square ( 16 )
Q27 Ask the user to enter a number with lots of decimal places. multiply this by
two and display the answer
num=float(input("enter a number with decimal places"))
print(num*2)
Q28 Update program 027 so that it will display the answer to two decimal places
num=float(input("enter a number with decimal places"))
answer=num*2
print(answer)
print(round(answer,2))
Q29 Ask the user to enter an integer that over 500. Work out the square root of
that number and display it to two decimal places.
import math
num=int(input("Enter a number over 500:-"))
answer=math.sqrt(num)
print(round(answer,2))
Q30. Display pi to five decimal places
import math
print(round(math.pi,5))
Q31. Ask the user to enter the radius of acircle (measurement from the center point
to the edge) work out the area of the circle(pi*radius2).
import math
radius=int(input("enter the radius of the circle:-"))
area=math.pi*(radius**2)
print(area)
Q32 Ask for the radius and the depth of acylinder and work out the total
volume(circle area *depth) round to three decimal places.
import math
radius=int(input("enter the radius of the circle:-"))
depth=int(input("enter depth:"))
area=math.pi*(radius**2)
volume=area*depth
print(round(volume,3))
Q33. Ask the user to enter two numbers. use whole number division to divide the
first number by second and also work out the remainder and display the answer in a
user-friendly way (e.g. if they enter 7 and 2 display “7 divided by 2 is 3 with 1
remaining”).
num1=int(input("enter a Number:"))
num2=int(input("enter another number:"))
ans1=num1//num2
ans2=num1%num2
print(num1, "divided by", num2 "is" , ans1, "with" , ans2, "remaining")