Started Rectangle Project
This commit is contained in:
commit
26e1253c0d
39 changed files with 544 additions and 0 deletions
21
homework06/DictionariesAndTry/dictionary0.py
Normal file
21
homework06/DictionariesAndTry/dictionary0.py
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
|
||||||
|
nameList = ["John", "Smith"]
|
||||||
|
nameDictionary = {'firstName': "John", 'lastName': "Smith", 'age': 24}
|
||||||
|
nameDictionary1 = {'firstName': "Mary", 'lastName': "Smith"}
|
||||||
|
|
||||||
|
namesList = [nameDictionary,nameDictionary1]
|
||||||
|
|
||||||
|
print(nameList)
|
||||||
|
print(nameDictionary)
|
||||||
|
print(namesList)
|
||||||
|
|
||||||
|
print(nameDictionary['firstName'])
|
||||||
|
print(nameDictionary['lastName'])
|
||||||
|
print(nameDictionary['age'])
|
||||||
|
|
||||||
|
print(nameDictionary1['firstName'])
|
||||||
|
print(nameDictionary1['lastName'])
|
||||||
|
|
||||||
|
# Uncomment this and it generates an error
|
||||||
|
#print(nameDictionary1['age'])
|
||||||
17
homework06/DictionariesAndTry/dictionary1.py
Normal file
17
homework06/DictionariesAndTry/dictionary1.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
#Tutorialspoint
|
||||||
|
# https://www.tutorialspoint.com/python/python_dictionary.htm
|
||||||
|
# Accessing Values in Dictionary
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
|
||||||
|
person = {'Name': 'Zara', 'Age': 7, 'Class': 'First','Color':'Green','Phone': "413-781-7822",'Email': "bgates@microsoft.com"}
|
||||||
|
|
||||||
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
|
pp.pprint(person)
|
||||||
|
print("\n")
|
||||||
|
|
||||||
|
print("person['Name']: ", person['Name'])
|
||||||
|
print ("person['Age']: ", person['Age'])
|
||||||
|
|
||||||
21
homework06/DictionariesAndTry/dictionary2.py
Normal file
21
homework06/DictionariesAndTry/dictionary2.py
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# An office directory example
|
||||||
|
|
||||||
|
dict = {'fName': 'Robert', 'lName': 'Smith', 'Office': 620, 'Phone': '413-755-0000',"Email": "rsmith@example.com"}
|
||||||
|
|
||||||
|
print("dict['fName'] dict['lName']: ", dict['fName']," ", dict['lName'])
|
||||||
|
print ("dict['Office']: ", dict['Office'])
|
||||||
|
print ("dict['Phone']: ", dict['Phone'])
|
||||||
|
|
||||||
|
#Uncomment this next line and the program fails
|
||||||
|
#print ("dict['Mobile']: ", dict['Mobile'])
|
||||||
|
|
||||||
|
try:
|
||||||
|
print("dict['fName'] dict['lName']: ", dict['fName']," ", dict['lName'])
|
||||||
|
print ("dict['Office']: ", dict['Office'])
|
||||||
|
print ("dict['Phone']: ", dict['Phone'])
|
||||||
|
print ("dict['Mobile']: ", dict['Mobile'])
|
||||||
|
except:
|
||||||
|
print("We are in the except block")
|
||||||
|
|
||||||
|
|
||||||
15
homework06/DictionariesAndTry/dictionary3.py
Normal file
15
homework06/DictionariesAndTry/dictionary3.py
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# A directory example
|
||||||
|
|
||||||
|
dict = {'fName': 'Edward', 'lName': 'Bigos', 'Office': 617, 'Phone': '413-755-4544'}
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
print("dict['fName'] dict['lName']: ", dict['fName']," ", dict['lName'])
|
||||||
|
print ("dict['Office']: ", dict['Office'])
|
||||||
|
print ("dict['Phone']: ", dict['Phone'])
|
||||||
|
print ("dict['Mobile']: ", dict['Mobile'])
|
||||||
|
except KeyError:
|
||||||
|
print("\nInvalid key selected.")
|
||||||
|
print("Sorry, there is no mobile phone number in the directory.")
|
||||||
|
print("\n")
|
||||||
14
homework06/DictionariesAndTry/dictionary3a.py
Normal file
14
homework06/DictionariesAndTry/dictionary3a.py
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# A directory example
|
||||||
|
|
||||||
|
dict = {'fName': 'Edward', 'lName': 'Bigos', 'Office': 617, 'Phone': '413-755-4544'}
|
||||||
|
try:
|
||||||
|
print("dict['fName'] dict['lName']: ", dict['fName']," ", dict['lName'])
|
||||||
|
print ("dict['Office']: ", dict['Office'])
|
||||||
|
print ("dict['Phone']: ", dict['Phone'])
|
||||||
|
# print ("dict['Mobile']: ", dict['Mobile'])
|
||||||
|
except KeyError:
|
||||||
|
print("Invalid key selected.")
|
||||||
|
print("Sorry, there is no key with that name in the directory.")
|
||||||
|
print("\n")
|
||||||
|
|
||||||
25
homework06/DictionariesAndTry/dictionary4.py
Normal file
25
homework06/DictionariesAndTry/dictionary4.py
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
# Create three dictionaries
|
||||||
|
dict1 = {'fName': 'Edward', 'lName': 'Bigos', 'Office': 617, 'Phone': '413-755-4544'}
|
||||||
|
dict2 = {'fName': 'Bill', 'lName': 'Gates', 'Office': 700, }
|
||||||
|
dict3 = {'fName': 'Harry', 'lName': 'Smith', 'Office': 677, 'Phone': '413-000-0000'}
|
||||||
|
|
||||||
|
# Put the three dictionaries in a list
|
||||||
|
staff = [dict1,dict2, dict3]
|
||||||
|
|
||||||
|
print(staff)
|
||||||
|
print("\n")
|
||||||
|
|
||||||
|
print("=============================\n\t\tDirectory\n=============================")
|
||||||
|
|
||||||
|
for person in staff:
|
||||||
|
# Person is a dictionary. Uncomment the next line to print the type.
|
||||||
|
#print(person, type(person))
|
||||||
|
try:
|
||||||
|
print(person['lName'], person['fName'], person['Phone'])
|
||||||
|
except:
|
||||||
|
print(person['lName'], person['fName'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
23
homework06/DictionariesAndTry/weather-data01.py
Normal file
23
homework06/DictionariesAndTry/weather-data01.py
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
weatherData = {'coord': {'lon': -72.5949, 'lat': 42.1726},
|
||||||
|
'weather': [{'id': 801, 'main': 'Clouds', 'description': 'few clouds', 'icon': '02n'}],
|
||||||
|
'base': 'stations',
|
||||||
|
'main': {'temp': 285.11, 'feels_like': 283.25, 'temp_min': 282.18, 'temp_max': 286.21,
|
||||||
|
'pressure': 1015, 'humidity': 34},
|
||||||
|
'visibility': 10000,
|
||||||
|
'wind': {'speed': 3.6, 'deg': 160},
|
||||||
|
'clouds': {'all': 20},
|
||||||
|
'dt': 1649723543,
|
||||||
|
'sys': {'type': 1, 'id': 3598, 'country': 'US', 'sunrise': 1649672158,
|
||||||
|
'sunset': 1649719584},
|
||||||
|
'timezone': -14400,
|
||||||
|
'id': 4933002,
|
||||||
|
'name': 'Chicopee',
|
||||||
|
'cod': 200}
|
||||||
|
|
||||||
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
|
|
||||||
|
pp.pprint(weatherData)
|
||||||
|
|
||||||
31
homework06/DictionariesAndTry/weather-data02.py
Normal file
31
homework06/DictionariesAndTry/weather-data02.py
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
weatherData = {'coord': {'lon': -72.5949, 'lat': 42.1726},
|
||||||
|
'weather': [{'id': 801, 'main': 'Clouds', 'description': 'few clouds', 'icon': '02n'}],
|
||||||
|
'base': 'stations',
|
||||||
|
'main': {'temp': 285.11, 'feels_like': 283.25, 'temp_min': 282.18, 'temp_max': 286.21,
|
||||||
|
'pressure': 1015, 'humidity': 34},
|
||||||
|
'visibility': 10000,
|
||||||
|
'wind': {'speed': 3.6, 'deg': 160},
|
||||||
|
'clouds': {'all': 20},
|
||||||
|
'dt': 1649723543,
|
||||||
|
'sys': {'type': 1, 'id': 3598, 'country': 'US', 'sunrise': 1649672158,
|
||||||
|
'sunset': 1649719584},
|
||||||
|
'timezone': -14400,
|
||||||
|
'id': 4933002,
|
||||||
|
'name': 'Chicopee',
|
||||||
|
'cod': 200}
|
||||||
|
|
||||||
|
#pp = pprint.PrettyPrinter(indent=4)
|
||||||
|
|
||||||
|
#pp.pprint(weatherData)
|
||||||
|
|
||||||
|
#print("\n")
|
||||||
|
|
||||||
|
print("coord",weatherData['coord'])
|
||||||
|
print("weather: ",weatherData['weather'])
|
||||||
|
print("base: ",weatherData['base'])
|
||||||
|
print("main: ",weatherData['main'])
|
||||||
|
print("wind: ",weatherData['wind'])
|
||||||
|
|
||||||
24
homework06/DictionariesAndTry/weather-data03.py
Normal file
24
homework06/DictionariesAndTry/weather-data03.py
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
weatherData = {'coord': {'lon': -72.5949, 'lat': 42.1726},
|
||||||
|
'weather': [{'id': 801, 'main': 'Clouds', 'description': 'few clouds', 'icon': '02n'}],
|
||||||
|
'base': 'stations',
|
||||||
|
'main': {'temp': 285.11, 'feels_like': 283.25, 'temp_min': 282.18, 'temp_max': 286.21,
|
||||||
|
'pressure': 1015, 'humidity': 34},
|
||||||
|
'visibility': 10000,
|
||||||
|
'wind': {'speed': 3.6, 'deg': 160},
|
||||||
|
'clouds': {'all': 20},
|
||||||
|
'dt': 1649723543,
|
||||||
|
'sys': {'type': 1, 'id': 3598, 'country': 'US', 'sunrise': 1649672158,
|
||||||
|
'sunset': 1649719584},
|
||||||
|
'timezone': -14400,
|
||||||
|
'id': 4933002,
|
||||||
|
'name': 'Chicopee',
|
||||||
|
'cod': 200}
|
||||||
|
|
||||||
|
|
||||||
|
print("\n\n======== Keys ===============")
|
||||||
|
for key in weatherData.keys():
|
||||||
|
print(key)
|
||||||
|
|
||||||
25
homework06/DictionariesAndTry/weather-data04.py
Normal file
25
homework06/DictionariesAndTry/weather-data04.py
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
weatherData = {'coord': {'lon': -72.5949, 'lat': 42.1726},
|
||||||
|
'weather': [{'id': 801, 'main': 'Clouds', 'description': 'few clouds', 'icon': '02n'}],
|
||||||
|
'base': 'stations',
|
||||||
|
'main': {'temp': 285.11, 'feels_like': 283.25, 'temp_min': 282.18, 'temp_max': 286.21,
|
||||||
|
'pressure': 1015, 'humidity': 34},
|
||||||
|
'visibility': 10000,
|
||||||
|
'wind': {'speed': 3.6, 'deg': 160},
|
||||||
|
'clouds': {'all': 20},
|
||||||
|
'dt': 1649723543,
|
||||||
|
'sys': {'type': 1, 'id': 3598, 'country': 'US', 'sunrise': 1649672158,
|
||||||
|
'sunset': 1649719584},
|
||||||
|
'timezone': -14400,
|
||||||
|
'id': 4933002,
|
||||||
|
'name': 'Chicopee',
|
||||||
|
'cod': 200}
|
||||||
|
|
||||||
|
|
||||||
|
print("\n\n======== Keys and Data ===============")
|
||||||
|
for key in weatherData.keys():
|
||||||
|
print(f" {key:12} {weatherData[key]} ")
|
||||||
|
|
||||||
|
|
||||||
45
homework06/functions/functions01.py
Normal file
45
homework06/functions/functions01.py
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
# Simple function examples
|
||||||
|
|
||||||
|
#No input parameters
|
||||||
|
def myFunction1():
|
||||||
|
print("You are in myFunction1")
|
||||||
|
|
||||||
|
|
||||||
|
# Two input patrameters
|
||||||
|
def myFunction2(x,y):
|
||||||
|
print("You are in myFunction2")
|
||||||
|
print("x = ",x)
|
||||||
|
print("y = ",y)
|
||||||
|
return(x + y)
|
||||||
|
|
||||||
|
# Two input parameters with predefined valiues.
|
||||||
|
# Provide one or no parameters. If not specified the default values will be used.
|
||||||
|
def myFunction3(x = 2,y = 3):
|
||||||
|
print("You are in myFunction3")
|
||||||
|
print("x = ",x)
|
||||||
|
print("y = ",y)
|
||||||
|
return(x + y)
|
||||||
|
|
||||||
|
# ======================== Main Program =============================
|
||||||
|
|
||||||
|
myFunction1()
|
||||||
|
|
||||||
|
retValue = myFunction2(3,4)
|
||||||
|
print(retValue)
|
||||||
|
|
||||||
|
retValue = myFunction2(5,6)
|
||||||
|
print(retValue)
|
||||||
|
|
||||||
|
# This generates an error
|
||||||
|
#retValue = myFunction2(4)
|
||||||
|
#print(retValue)
|
||||||
|
|
||||||
|
retValue = myFunction3(3,4)
|
||||||
|
print(retValue)
|
||||||
|
|
||||||
|
retValue = myFunction3(5)
|
||||||
|
print(retValue)
|
||||||
|
|
||||||
|
# This does not generate an error
|
||||||
|
retValue = myFunction3()
|
||||||
|
print(retValue)
|
||||||
16
homework06/functions/functions02.py
Normal file
16
homework06/functions/functions02.py
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
# list as an input parameter
|
||||||
|
def myFunction4(listParameter):
|
||||||
|
for listItem in listParameter:
|
||||||
|
print("\tlistParameter item: ",listItem)
|
||||||
|
myList = listParameter
|
||||||
|
myList.sort()
|
||||||
|
return( myList ) # Return a list
|
||||||
|
|
||||||
|
# ======================== Main Program =============================
|
||||||
|
|
||||||
|
fruits = ['Mango','Banana','Cherry', 'Apples']
|
||||||
|
print("\n Starting list: ",fruits)
|
||||||
|
print("\n")
|
||||||
|
|
||||||
|
sortedFruits = myFunction4(fruits)
|
||||||
|
print("\n Returned list: ",sortedFruits)
|
||||||
25
homework06/functions/functions03.py
Normal file
25
homework06/functions/functions03.py
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
def updatePerson(personDict):
|
||||||
|
myPerson = personDict
|
||||||
|
|
||||||
|
emailAddress = input("Enter your email address: ")
|
||||||
|
phoneNumber = input("Enter your phone number: ")
|
||||||
|
myPerson['email'] = emailAddress
|
||||||
|
myPerson['phone'] = phoneNumber
|
||||||
|
|
||||||
|
return myPerson
|
||||||
|
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
person = {'Name': 'Zara', 'Age': 7, 'Class': 'First','Color':'Green'}
|
||||||
|
|
||||||
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
|
pp.pprint(person)
|
||||||
|
print("\n")
|
||||||
|
|
||||||
|
for key in person.keys():
|
||||||
|
print(f" {key:12} {person[key]} ")
|
||||||
|
|
||||||
|
person2 = updatePerson(person)
|
||||||
|
for key in person2.keys():
|
||||||
|
print(f" {key:12} {person2[key]} ")
|
||||||
|
|
||||||
40
homework06/functions/functions04.py
Normal file
40
homework06/functions/functions04.py
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
# Simple function examples
|
||||||
|
|
||||||
|
def rectanglePerimeter(rLength,rWidth):
|
||||||
|
'''
|
||||||
|
rLength: length of the rectangle.
|
||||||
|
|
||||||
|
rWidth: width of the rectangle.
|
||||||
|
|
||||||
|
Returns the perimeter of the rectangle.'''
|
||||||
|
perimeter = 2 * (rLength + rWidth)
|
||||||
|
return(perimeter)
|
||||||
|
|
||||||
|
def rectangleArea(rLength,rWidth):
|
||||||
|
area = rLength * rWidth
|
||||||
|
return(area)
|
||||||
|
|
||||||
|
def squarePerimeter(rLength):
|
||||||
|
perimeter = rectanglePerimeter(rLength,rLength)
|
||||||
|
return(perimeter)
|
||||||
|
|
||||||
|
def squareArea(rLength):
|
||||||
|
area = rectangleArea(rLength,rLength)
|
||||||
|
return(area)
|
||||||
|
|
||||||
|
# ======================== Main Program =============================
|
||||||
|
|
||||||
|
length = 2.
|
||||||
|
width = 3.
|
||||||
|
|
||||||
|
retValue = rectanglePerimeter(length,width)
|
||||||
|
print(retValue)
|
||||||
|
|
||||||
|
retValue = rectangleArea(length,width)
|
||||||
|
print(retValue)
|
||||||
|
|
||||||
|
retValue = squarePerimeter(length)
|
||||||
|
print(retValue)
|
||||||
|
|
||||||
|
retValue = squareArea(length)
|
||||||
|
print(retValue)
|
||||||
3
homework06/git-practice/.idea/.gitignore
generated
vendored
Normal file
3
homework06/git-practice/.idea/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
8
homework06/git-practice/.idea/git-practice.iml
generated
Normal file
8
homework06/git-practice/.idea/git-practice.iml
generated
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
homework06/git-practice/.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
homework06/git-practice/.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
4
homework06/git-practice/.idea/misc.xml
generated
Normal file
4
homework06/git-practice/.idea/misc.xml
generated
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (2)" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
||||||
8
homework06/git-practice/.idea/modules.xml
generated
Normal file
8
homework06/git-practice/.idea/modules.xml
generated
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/git-practice.iml" filepath="$PROJECT_DIR$/.idea/git-practice.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
7
homework06/git-practice/README.txt
Normal file
7
homework06/git-practice/README.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
This is the "Rectangular Project". As you will see this may have
|
||||||
|
been a bad choice of naming.
|
||||||
|
|
||||||
|
This is also a file to keep Windows Zip program happy. Windows Zip
|
||||||
|
will not include an empty directory.
|
||||||
|
|
||||||
|
Ed
|
||||||
BIN
homework06/program-files/.DS_Store
vendored
Normal file
BIN
homework06/program-files/.DS_Store
vendored
Normal file
Binary file not shown.
7
homework06/program-files/1 - start/README.txt
Normal file
7
homework06/program-files/1 - start/README.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
This is the "Rectangular Project". As you will see this may have
|
||||||
|
been a bad choice of naming.
|
||||||
|
|
||||||
|
Step 8 renames a mis-spelled program rectanglar-solid.py to
|
||||||
|
rectangular-solid.py using the git mv command.
|
||||||
|
|
||||||
|
Ed
|
||||||
7
homework06/program-files/1 - start/rectangle01.py
Normal file
7
homework06/program-files/1 - start/rectangle01.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
length = 4
|
||||||
|
width = 3
|
||||||
|
|
||||||
|
areaOfRectangle = length * width
|
||||||
|
|
||||||
|
print("Area = ",areaOfRectangle)
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
length = float(input("Enter a value for length "))
|
||||||
|
width = float(input("Enter a value for width "))
|
||||||
|
|
||||||
|
areaOfRectangle = length * width
|
||||||
|
|
||||||
|
print("Area = ",areaOfRectangle)
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
length = float(input("Enter a value for length "))
|
||||||
|
width = float(input("Enter a value for width "))
|
||||||
|
|
||||||
|
areaOfRectangle = length * width
|
||||||
|
|
||||||
|
print(f"Area = {areaOfRectangle:.2f}")
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
length = float(input("Enter a value for length "))
|
||||||
|
width = float(input("Enter a value for width "))
|
||||||
|
height = float(input("Enter a value for height "))
|
||||||
|
|
||||||
|
volumeOfRectangle = length * width * height
|
||||||
|
|
||||||
|
print(f"Area = {volumeOfRectangle:.2f}")
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
length = float(input("Enter a value for length "))
|
||||||
|
width = float(input("Enter a value for width "))
|
||||||
|
height = float(input("Enter a value for height "))
|
||||||
|
|
||||||
|
volumeOfRectangle = length * width * height
|
||||||
|
|
||||||
|
print(f"Area = {volumeOfRectangle:.1f}")
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
length = float(input("Enter a value for length "))
|
||||||
|
width = float(input("Enter a value for width "))
|
||||||
|
|
||||||
|
areaOfRectangle = length * width
|
||||||
|
|
||||||
|
print(f"Area = {areaOfRectangle:.1f}")
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
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}")
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
length = float(input("Enter a value for the length "))
|
||||||
|
width = float(input("Enter a value for the width "))
|
||||||
|
|
||||||
|
areaOfRectangle = length * width
|
||||||
|
|
||||||
|
print(f"Area = {areaOfRectangle:.1f}")
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
import math
|
||||||
|
PI = math.pi
|
||||||
|
|
||||||
|
radius = float(input("Enter the radius of a circle "))
|
||||||
|
|
||||||
|
area = PI * radius**2
|
||||||
|
|
||||||
|
print(f"The area is {area}")
|
||||||
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
import math
|
||||||
|
PI = math.pi
|
||||||
|
|
||||||
|
radius = float(input("Enter the radius of a sphere "))
|
||||||
|
|
||||||
|
|
||||||
|
volume = 4 / 3 * PI * radius**3
|
||||||
|
|
||||||
|
print(f"The volume of the sphere is {volume}")
|
||||||
BIN
homework06/program-files/8 - Rename one program file/.DS_Store
vendored
Normal file
BIN
homework06/program-files/8 - Rename one program file/.DS_Store
vendored
Normal file
Binary file not shown.
|
|
@ -0,0 +1,10 @@
|
||||||
|
This is the "Rectangular Project". As you will see this may have
|
||||||
|
been a bad choice of naming.
|
||||||
|
|
||||||
|
Step 8 renames a mis-spelled program rectanglar-solid.py to
|
||||||
|
rectangular-solid.py using the git mv command. Note the name
|
||||||
|
of the file in the directory and the git repo changes and is
|
||||||
|
associated.
|
||||||
|
|
||||||
|
|
||||||
|
Ed
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Program circle1.py
|
||||||
|
|
||||||
|
startUpMessage = '''
|
||||||
|
This program calculates the area of a circle.
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
print(startUpMessage)
|
||||||
|
|
||||||
|
import math
|
||||||
|
PI = math.pi
|
||||||
|
|
||||||
|
radius = float(input("Enter the radius of a circle "))
|
||||||
|
|
||||||
|
area = PI * radius**2
|
||||||
|
|
||||||
|
print(f"The area is {area:.2f}")
|
||||||
|
print("\n")
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Program rectangle01.py
|
||||||
|
|
||||||
|
startUpMessage = '''
|
||||||
|
This program calculates the area of a rectangle.
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
print(startUpMessage)
|
||||||
|
|
||||||
|
length = float(input("Enter a value for the length "))
|
||||||
|
width = float(input("Enter a value for the width "))
|
||||||
|
|
||||||
|
areaOfRectangle = length * width
|
||||||
|
|
||||||
|
print(f"Area = {areaOfRectangle:.1f}")
|
||||||
|
print("\n")
|
||||||
|
|
@ -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")
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Program sphere1.py
|
||||||
|
|
||||||
|
startUpMessage = '''
|
||||||
|
This program calculates the volume of a sphere.
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
print(startUpMessage)
|
||||||
|
|
||||||
|
|
||||||
|
import math
|
||||||
|
PI = math.pi
|
||||||
|
|
||||||
|
radius = float(input("Enter the radius of a sphere "))
|
||||||
|
|
||||||
|
|
||||||
|
volume = 4 / 3 * PI * radius**3
|
||||||
|
|
||||||
|
print(f"The volume of the sphere is {volume:.2f}")
|
||||||
1
homework06/results/readme.txt
Normal file
1
homework06/results/readme.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Submit all files in this directory.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue