From 26e1253c0de3ed578f2a1cdd90d8635e3c7c83c5 Mon Sep 17 00:00:00 2001 From: cmitchell2301 Date: Sun, 14 Dec 2025 18:34:36 -0500 Subject: [PATCH] Started Rectangle Project --- homework06/DictionariesAndTry/dictionary0.py | 21 ++++++++ homework06/DictionariesAndTry/dictionary1.py | 17 +++++++ homework06/DictionariesAndTry/dictionary2.py | 21 ++++++++ homework06/DictionariesAndTry/dictionary3.py | 15 ++++++ homework06/DictionariesAndTry/dictionary3a.py | 14 ++++++ homework06/DictionariesAndTry/dictionary4.py | 25 ++++++++++ .../DictionariesAndTry/weather-data01.py | 23 +++++++++ .../DictionariesAndTry/weather-data02.py | 31 ++++++++++++ .../DictionariesAndTry/weather-data03.py | 24 ++++++++++ .../DictionariesAndTry/weather-data04.py | 25 ++++++++++ homework06/functions/functions01.py | 45 ++++++++++++++++++ homework06/functions/functions02.py | 16 +++++++ homework06/functions/functions03.py | 25 ++++++++++ homework06/functions/functions04.py | 40 ++++++++++++++++ homework06/git-practice/.idea/.gitignore | 3 ++ .../git-practice/.idea/git-practice.iml | 8 ++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ homework06/git-practice/.idea/misc.xml | 4 ++ homework06/git-practice/.idea/modules.xml | 8 ++++ homework06/git-practice/README.txt | 7 +++ homework06/program-files/.DS_Store | Bin 0 -> 10244 bytes homework06/program-files/1 - start/README.txt | 7 +++ .../program-files/1 - start/rectangle01.py | 7 +++ .../2 - Input statements/rectangle01.py | 7 +++ .../3 - formatted print/rectangle01.py | 7 +++ .../rectanglar-solid01.py | 8 ++++ .../rectanglar-solid01.py | 8 ++++ .../rectangle01.py | 7 +++ .../rectanglar-solid01.py | 8 ++++ .../rectangle01.py | 7 +++ .../circle1.py | 9 ++++ .../sphere1.py | 10 ++++ .../8 - Rename one program file/.DS_Store | Bin 0 -> 6148 bytes .../8 - Rename one program file/README.txt | 10 ++++ .../circle1.py | 18 +++++++ .../rectangle01.py | 16 +++++++ .../rectangular-solid01.py | 17 +++++++ .../sphere1.py | 19 ++++++++ homework06/results/readme.txt | 1 + 39 files changed, 544 insertions(+) create mode 100644 homework06/DictionariesAndTry/dictionary0.py create mode 100644 homework06/DictionariesAndTry/dictionary1.py create mode 100644 homework06/DictionariesAndTry/dictionary2.py create mode 100644 homework06/DictionariesAndTry/dictionary3.py create mode 100644 homework06/DictionariesAndTry/dictionary3a.py create mode 100644 homework06/DictionariesAndTry/dictionary4.py create mode 100644 homework06/DictionariesAndTry/weather-data01.py create mode 100644 homework06/DictionariesAndTry/weather-data02.py create mode 100644 homework06/DictionariesAndTry/weather-data03.py create mode 100644 homework06/DictionariesAndTry/weather-data04.py create mode 100644 homework06/functions/functions01.py create mode 100644 homework06/functions/functions02.py create mode 100644 homework06/functions/functions03.py create mode 100644 homework06/functions/functions04.py create mode 100644 homework06/git-practice/.idea/.gitignore create mode 100644 homework06/git-practice/.idea/git-practice.iml create mode 100644 homework06/git-practice/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 homework06/git-practice/.idea/misc.xml create mode 100644 homework06/git-practice/.idea/modules.xml create mode 100644 homework06/git-practice/README.txt create mode 100644 homework06/program-files/.DS_Store create mode 100644 homework06/program-files/1 - start/README.txt create mode 100644 homework06/program-files/1 - start/rectangle01.py create mode 100644 homework06/program-files/2 - Input statements/rectangle01.py create mode 100644 homework06/program-files/3 - formatted print/rectangle01.py create mode 100644 homework06/program-files/4 - Added rectangular-solid1/rectanglar-solid01.py create mode 100644 homework06/program-files/5 - Modified print format precision/rectanglar-solid01.py create mode 100644 homework06/program-files/5 - Modified print format precision/rectangle01.py create mode 100644 homework06/program-files/6 - Corrected text seen by user/rectanglar-solid01.py create mode 100644 homework06/program-files/6 - Corrected text seen by user/rectangle01.py create mode 100644 homework06/program-files/7 - Added circle and sphere programs/circle1.py create mode 100644 homework06/program-files/7 - Added circle and sphere programs/sphere1.py create mode 100644 homework06/program-files/8 - Rename one program file/.DS_Store create mode 100644 homework06/program-files/8 - Rename one program file/README.txt create mode 100644 homework06/program-files/9 - Added documentation and info to the user/circle1.py create mode 100644 homework06/program-files/9 - Added documentation and info to the user/rectangle01.py create mode 100644 homework06/program-files/9 - Added documentation and info to the user/rectangular-solid01.py create mode 100644 homework06/program-files/9 - Added documentation and info to the user/sphere1.py create mode 100644 homework06/results/readme.txt diff --git a/homework06/DictionariesAndTry/dictionary0.py b/homework06/DictionariesAndTry/dictionary0.py new file mode 100644 index 0000000..dd8d88f --- /dev/null +++ b/homework06/DictionariesAndTry/dictionary0.py @@ -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']) diff --git a/homework06/DictionariesAndTry/dictionary1.py b/homework06/DictionariesAndTry/dictionary1.py new file mode 100644 index 0000000..b6da735 --- /dev/null +++ b/homework06/DictionariesAndTry/dictionary1.py @@ -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']) + diff --git a/homework06/DictionariesAndTry/dictionary2.py b/homework06/DictionariesAndTry/dictionary2.py new file mode 100644 index 0000000..67f9210 --- /dev/null +++ b/homework06/DictionariesAndTry/dictionary2.py @@ -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") + + diff --git a/homework06/DictionariesAndTry/dictionary3.py b/homework06/DictionariesAndTry/dictionary3.py new file mode 100644 index 0000000..cce449c --- /dev/null +++ b/homework06/DictionariesAndTry/dictionary3.py @@ -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") diff --git a/homework06/DictionariesAndTry/dictionary3a.py b/homework06/DictionariesAndTry/dictionary3a.py new file mode 100644 index 0000000..e158e6b --- /dev/null +++ b/homework06/DictionariesAndTry/dictionary3a.py @@ -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") + diff --git a/homework06/DictionariesAndTry/dictionary4.py b/homework06/DictionariesAndTry/dictionary4.py new file mode 100644 index 0000000..c2fd2cf --- /dev/null +++ b/homework06/DictionariesAndTry/dictionary4.py @@ -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']) + + + diff --git a/homework06/DictionariesAndTry/weather-data01.py b/homework06/DictionariesAndTry/weather-data01.py new file mode 100644 index 0000000..45dc805 --- /dev/null +++ b/homework06/DictionariesAndTry/weather-data01.py @@ -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) + diff --git a/homework06/DictionariesAndTry/weather-data02.py b/homework06/DictionariesAndTry/weather-data02.py new file mode 100644 index 0000000..cb38f43 --- /dev/null +++ b/homework06/DictionariesAndTry/weather-data02.py @@ -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']) + diff --git a/homework06/DictionariesAndTry/weather-data03.py b/homework06/DictionariesAndTry/weather-data03.py new file mode 100644 index 0000000..7ba1b80 --- /dev/null +++ b/homework06/DictionariesAndTry/weather-data03.py @@ -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) + diff --git a/homework06/DictionariesAndTry/weather-data04.py b/homework06/DictionariesAndTry/weather-data04.py new file mode 100644 index 0000000..9d46783 --- /dev/null +++ b/homework06/DictionariesAndTry/weather-data04.py @@ -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]} ") + + diff --git a/homework06/functions/functions01.py b/homework06/functions/functions01.py new file mode 100644 index 0000000..f0484d8 --- /dev/null +++ b/homework06/functions/functions01.py @@ -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) diff --git a/homework06/functions/functions02.py b/homework06/functions/functions02.py new file mode 100644 index 0000000..bbfbf6b --- /dev/null +++ b/homework06/functions/functions02.py @@ -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) diff --git a/homework06/functions/functions03.py b/homework06/functions/functions03.py new file mode 100644 index 0000000..f35a1e3 --- /dev/null +++ b/homework06/functions/functions03.py @@ -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]} ") + diff --git a/homework06/functions/functions04.py b/homework06/functions/functions04.py new file mode 100644 index 0000000..be36709 --- /dev/null +++ b/homework06/functions/functions04.py @@ -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) diff --git a/homework06/git-practice/.idea/.gitignore b/homework06/git-practice/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/homework06/git-practice/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/homework06/git-practice/.idea/git-practice.iml b/homework06/git-practice/.idea/git-practice.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/homework06/git-practice/.idea/git-practice.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/homework06/git-practice/.idea/inspectionProfiles/profiles_settings.xml b/homework06/git-practice/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/homework06/git-practice/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/homework06/git-practice/.idea/misc.xml b/homework06/git-practice/.idea/misc.xml new file mode 100644 index 0000000..8788511 --- /dev/null +++ b/homework06/git-practice/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/homework06/git-practice/.idea/modules.xml b/homework06/git-practice/.idea/modules.xml new file mode 100644 index 0000000..d408cf7 --- /dev/null +++ b/homework06/git-practice/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/homework06/git-practice/README.txt b/homework06/git-practice/README.txt new file mode 100644 index 0000000..1dfe20d --- /dev/null +++ b/homework06/git-practice/README.txt @@ -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 diff --git a/homework06/program-files/.DS_Store b/homework06/program-files/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..860c5d45c6b5a2b42c2f09b55527db85a9347d3f GIT binary patch literal 10244 zcmeI1&ubGw6vy9a4-q{G)sspWwCKTtiCXoR)_Cxs2O}QDLz`^c2KE=5L=*(`C*-LA zfJYGoJ$MuRBNRM%@?Y@i_svY)!AvF1PKuD3F!Q#v^WO44`}Xa=DG`ayL0BaUh^T_j z^5h8&md59~PqZU?W))IEpQuND+NPZP(eA`*Kj8^@0-k^;;0bsF{{sQMv$<7{E9pm1 zz!UHU{t)2&5TLWHYdKU>rVb3U1b|$^v}`y=9UyfAE$dnim6WQmsj3H|RfR4wgi^=( zfR{towHzv`)JZ6H68g$QS13YW9eROWPNJ@)A3Xt2V3GjW?#HN#r)>@0sNbv2b{c1f zf@M{lHX5xcZDCdA?W1=WSH6DPu-l8%aLSe0-ZWQ!+RT$EO?a1q6T&H~X%FsFLKzLP z4>9(pPaTTU6U_CZ-3jYc>zdxaZ2f$!y*+?_!C)4B3z=oQs{P)f6#FhQc3=AVbtuGq zhM6w=ZSi_aP1EO(wd|Gld1~##g&9REewb_*B)iZ{ zEEFACHkm%zTK%P&IDUF9MaROIt0ty0dEGd4X- zaXz-@e`mH$#verXUNd%Rzo0!2`xfqJ=%(iWK*lLEWU9yo7P_22x_mb*@jIg>lj-Pw z zz~T`QOO0k@6Ml<*eCNIP0DTLc8?PHGDOE7Y?RZGJ9gjbFJN^H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0