Added documantion and information to the programs
This commit is contained in:
parent
a2259b5b98
commit
db095e828d
4 changed files with 48 additions and 4 deletions
13
circle1.py
13
circle1.py
|
|
@ -1,3 +1,12 @@
|
||||||
|
# Program circle1.py
|
||||||
|
|
||||||
|
startUpMessage = '''
|
||||||
|
This program calculates the area of a circle.
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
print(startUpMessage)
|
||||||
|
|
||||||
import math
|
import math
|
||||||
PI = math.pi
|
PI = math.pi
|
||||||
|
|
||||||
|
|
@ -5,5 +14,5 @@ radius = float(input("Enter the radius of a circle "))
|
||||||
|
|
||||||
area = PI * radius**2
|
area = PI * radius**2
|
||||||
|
|
||||||
print(f"The area is {area}")
|
print(f"The area is {area:.2f}")
|
||||||
|
print("\n")
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,11 @@
|
||||||
|
# Program rectangle01.py
|
||||||
|
|
||||||
|
startUpMessage = '''
|
||||||
|
This program calculates the area of a rectangle.
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
print(startUpMessage)
|
||||||
|
|
||||||
length = float(input("Enter a value for the length "))
|
length = float(input("Enter a value for the length "))
|
||||||
width = float(input("Enter a value for the width "))
|
width = float(input("Enter a value for the width "))
|
||||||
|
|
@ -5,3 +13,4 @@ width = float(input("Enter a value for the width "))
|
||||||
areaOfRectangle = length * width
|
areaOfRectangle = length * width
|
||||||
|
|
||||||
print(f"Area = {areaOfRectangle:.1f}")
|
print(f"Area = {areaOfRectangle:.1f}")
|
||||||
|
print("\n")
|
||||||
17
rectangular-solid01.py
Normal file
17
rectangular-solid01.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Program rectanglar-solid.py
|
||||||
|
|
||||||
|
startUpMessage = '''
|
||||||
|
This program calculates the volume of a rectangular solid.
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
print(startUpMessage)
|
||||||
|
|
||||||
|
length = float(input("Enter a value for the length "))
|
||||||
|
width = float(input("Enter a value for the width "))
|
||||||
|
height = float(input("Enter a value for the height "))
|
||||||
|
|
||||||
|
volumeOfRectangle = length * width * height
|
||||||
|
|
||||||
|
print(f"Volume = {volumeOfRectangle:.1f}")
|
||||||
|
print("\n")
|
||||||
11
sphere1.py
11
sphere1.py
|
|
@ -1,3 +1,12 @@
|
||||||
|
# Program sphere1.py
|
||||||
|
|
||||||
|
startUpMessage = '''
|
||||||
|
This program calculates the volume of a sphere.
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
print(startUpMessage)
|
||||||
|
|
||||||
|
|
||||||
import math
|
import math
|
||||||
PI = math.pi
|
PI = math.pi
|
||||||
|
|
@ -7,4 +16,4 @@ radius = float(input("Enter the radius of a sphere "))
|
||||||
|
|
||||||
volume = 4 / 3 * PI * radius**3
|
volume = 4 / 3 * PI * radius**3
|
||||||
|
|
||||||
print(f"The volume of the sphere is {volume}")
|
print(f"The volume of the sphere is {volume:.2f}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue