From d791ed3aa58ae20e7e998f23f5f908e3ce09cd87 Mon Sep 17 00:00:00 2001 From: TJT Date: Tue, 4 Sep 2018 20:35:53 -0400 Subject: [PATCH 01/20] Added Name To FIle Updated branch readme.md file --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index af9ff9c..a47165b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1 @@ -## Programming-With-Python - -# Welcome - -### This repository is currently under construction to prepare for FIT-ACM and Florida Institute of Technology Evan's Library Programming with Python camp +{# Travis} \ No newline at end of file From 49de7e64428d4158c11727ed019b14048f83b62f Mon Sep 17 00:00:00 2001 From: TJT Date: Tue, 4 Sep 2018 22:48:38 -0400 Subject: [PATCH 02/20] Updated README.md file content --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a47165b..40a353c 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -{# Travis} \ No newline at end of file +{# Travis Thomas} \ No newline at end of file From ac9d628091cdf2feb75737c1598b6dd86da71c80 Mon Sep 17 00:00:00 2001 From: TJT Date: Tue, 4 Sep 2018 22:55:37 -0400 Subject: [PATCH 03/20] Adding HelloWorld Python File --- HelloWorld.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 HelloWorld.py diff --git a/HelloWorld.py b/HelloWorld.py new file mode 100644 index 0000000..8e23576 --- /dev/null +++ b/HelloWorld.py @@ -0,0 +1 @@ +print("Hello World") \ No newline at end of file From 57e8aa888dd82cb1bb14168e4947cbe11729bba7 Mon Sep 17 00:00:00 2001 From: TJT Date: Sun, 9 Sep 2018 14:36:22 -0400 Subject: [PATCH 04/20] Added Original MadLibs.py code --- MadLibs.py | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 MadLibs.py diff --git a/MadLibs.py b/MadLibs.py new file mode 100644 index 0000000..e0d368e --- /dev/null +++ b/MadLibs.py @@ -0,0 +1,88 @@ +#Instantiate variables for use later +sInitialPrompt = '\nPress ENTER to begin.' +sAdjListPrompt = '\nEnter 4 adjectives, separated by commas: ' +sVerbListPrompt1 = 'Enter a past tense verb: ' +sVerbListPrompt2 = 'Enter a present tense verb: ' +sVerbListPrompt3 = 'Enter two -ing ending verbs, separated by a comma: ' +sNounPrompt1 = 'Enter a singular noun: ' +sNounPrompt2 = 'Enter a plural noun: ' +sNounPrompt3 = 'Enter a type of liquid: ' +sNounPrompt4 = 'Enter the name of a room in a house: ' +sFinalPrompt = '\nAll done! Press Enter to see your Mad Lib Results!' + + + +#Below int definitions will be used only if have time to count the number of entries entered in a comma separated list + #by the end user and re-prompt for additional, missing entries. +#intNumAdj = int(4) +#intNumNoun = int(3) +#intNumVerb = int(2) + +def Main(): +# Print introductory remarks to screen + print('Mad Libs Project - Written by Travis Thomas' + '\n\n\t *** Title: COPING WITH CHILDHOOD FEARS ***' + '\n\nWelcome to Mad Libs!' + '\n\nYou will be given a series of prompts for which to enter values.' + '\nWhen you finish, your entries will be inserted into a pre-made paragraph.' + '\nHopeully the results will be funny! Enjoy!') + + #Kickoff User Prompts + KickoffPrompt = input(sInitialPrompt) + +#Obtain user's adjective list and use input to define list variable + # AdjPrompt: List = input(sAdjListPrompt) + sAdjsEntered = input(sAdjListPrompt) + StrSplit_Adj = sAdjsEntered.split(',',4) + lstAllAdjsEntered: List = StrSplit_Adj + #cntlst = count.lstAdjsEntered #need to figure out this syntax + +#Obtain user's mutiple verb entries, and form list for indexing later + lstVerb1 = [input(sVerbListPrompt1)] + + lstVerb2 = [input(sVerbListPrompt2)] + #Parse string variable into comma-separated list + # StrSplit_slstVerb2 = slstVerb2.split(',',2) + #Instantiate variable with new comma-separated list for readability + # lstVerb2: List = StrSplit_slstVerb2 + + slstVerb3 = input(sVerbListPrompt3) + # Parse string variable into comma-separated list + StrSplit_slstVerb3 = slstVerb3.split(',',2) + #Instantiate variable with new comma-separated list for readability + lstVerb3: List = StrSplit_slstVerb3 + + #Place ALL verbs entered into 1 list + lstAllVerbsEntered = lstVerb1 + lstVerb2 + lstVerb3 + +#Obtain user's mutiple noun entries, and form list for indexing later + slstNoun1 = [input(sNounPrompt1)] + slstNoun2 = [input(sNounPrompt2)] + slstNoun3 = [input(sNounPrompt3)] + slstNoun4 = [input(sNounPrompt4)] + + # Place ALL nouns entered into 1 list + lstAllNounsEntered = slstNoun1 + slstNoun2 + slstNoun3 + slstNoun4 + + +#test input structure. comment all below entries out from final output. +# print('\t* lstAdjsEntered = ', lstAllAdjsEntered) +# print('\t* lstAllVerbsEntered = ', lstAllVerbsEntered) +# print('\t* lstAllNounsEntered = ', lstAllNounsEntered) + +#Final Mad Libs Output + FinalPrompt = input(sFinalPrompt) + +# sFinalOutPut: str = '\nWhen I was little, I was afraid of ' + lstAllNounsEntered[1] + '.' + print('\nWhen I was little, I was afraid of {}.'.format(lstAllNounsEntered[1]), + 'I found them to be simply {}.'.format(lstAllAdjsEntered[0]), + '\nNone of my{} classmates could understand, and they'.format(lstAllAdjsEntered[1]), + lstAllVerbsEntered[0], 'about it constantly.\nBut what can you expect from{}'.format(lstAllAdjsEntered[1]), + 'people?\nNowadays, I cope by {}'.format(lstAllVerbsEntered[2]), 'loudly and{} {}'.format(lstAllVerbsEntered[3], + lstAllNounsEntered[2]), 'all around my {}.'.format(lstAllNounsEntered[3]), '\nIt’s surprisingly ' + 'therapeutic! You wouldn’t think it would work since it sounds\nso{}.'.format(lstAllAdjsEntered[2]), + 'I guess it just goes to show that even a(n){} {}'.format(lstAllAdjsEntered[3], lstAllNounsEntered[0]), + 'can {},'.format(lstAllVerbsEntered[1]), 'too!' + ) + +Main() \ No newline at end of file From cd0a027c6bc87517cbcd6cdd12bc31fe8903dd29 Mon Sep 17 00:00:00 2001 From: TJT Date: Sun, 9 Sep 2018 14:49:58 -0400 Subject: [PATCH 05/20] Initial upload of MadLibs.py app code. --- MadLibs.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/MadLibs.py b/MadLibs.py index e0d368e..b461646 100644 --- a/MadLibs.py +++ b/MadLibs.py @@ -13,7 +13,7 @@ #Below int definitions will be used only if have time to count the number of entries entered in a comma separated list - #by the end user and re-prompt for additional, missing entries. +#by the end user and re-prompt for additional, missing entries. #intNumAdj = int(4) #intNumNoun = int(3) #intNumVerb = int(2) @@ -31,7 +31,6 @@ def Main(): KickoffPrompt = input(sInitialPrompt) #Obtain user's adjective list and use input to define list variable - # AdjPrompt: List = input(sAdjListPrompt) sAdjsEntered = input(sAdjListPrompt) StrSplit_Adj = sAdjsEntered.split(',',4) lstAllAdjsEntered: List = StrSplit_Adj @@ -56,14 +55,13 @@ def Main(): lstAllVerbsEntered = lstVerb1 + lstVerb2 + lstVerb3 #Obtain user's mutiple noun entries, and form list for indexing later - slstNoun1 = [input(sNounPrompt1)] - slstNoun2 = [input(sNounPrompt2)] - slstNoun3 = [input(sNounPrompt3)] - slstNoun4 = [input(sNounPrompt4)] + lstNoun1 = [input(sNounPrompt1)] + lstNoun2 = [input(sNounPrompt2)] + lstNoun3 = [input(sNounPrompt3)] + lstNoun4 = [input(sNounPrompt4)] # Place ALL nouns entered into 1 list - lstAllNounsEntered = slstNoun1 + slstNoun2 + slstNoun3 + slstNoun4 - + lstAllNounsEntered = lstNoun1 + lstNoun2 + lstNoun3 + lstNoun4 #test input structure. comment all below entries out from final output. # print('\t* lstAdjsEntered = ', lstAllAdjsEntered) From 411cca5a94671e3db2a3742ebe67a2857f27b42e Mon Sep 17 00:00:00 2001 From: TJT Date: Sun, 9 Sep 2018 20:34:17 -0400 Subject: [PATCH 06/20] General code refinements --- MadLibs.py | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/MadLibs.py b/MadLibs.py index b461646..d0ff2f4 100644 --- a/MadLibs.py +++ b/MadLibs.py @@ -10,14 +10,6 @@ sNounPrompt4 = 'Enter the name of a room in a house: ' sFinalPrompt = '\nAll done! Press Enter to see your Mad Lib Results!' - - -#Below int definitions will be used only if have time to count the number of entries entered in a comma separated list -#by the end user and re-prompt for additional, missing entries. -#intNumAdj = int(4) -#intNumNoun = int(3) -#intNumVerb = int(2) - def Main(): # Print introductory remarks to screen print('Mad Libs Project - Written by Travis Thomas' @@ -30,31 +22,20 @@ def Main(): #Kickoff User Prompts KickoffPrompt = input(sInitialPrompt) -#Obtain user's adjective list and use input to define list variable - sAdjsEntered = input(sAdjListPrompt) - StrSplit_Adj = sAdjsEntered.split(',',4) - lstAllAdjsEntered: List = StrSplit_Adj - #cntlst = count.lstAdjsEntered #need to figure out this syntax +# Obtain user's adjective list and use input to define list variable + lstAllAdjsEntered: list = input(sAdjListPrompt).split(',',4) -#Obtain user's mutiple verb entries, and form list for indexing later +# Obtain user's mutiple verb entries, and form list for indexing later lstVerb1 = [input(sVerbListPrompt1)] lstVerb2 = [input(sVerbListPrompt2)] - #Parse string variable into comma-separated list - # StrSplit_slstVerb2 = slstVerb2.split(',',2) - #Instantiate variable with new comma-separated list for readability - # lstVerb2: List = StrSplit_slstVerb2 + # Receive user input, parse into single items leveraging the "," and store in variable as a list. + lstVerb3: list = input(sVerbListPrompt3).split(',',2) - slstVerb3 = input(sVerbListPrompt3) - # Parse string variable into comma-separated list - StrSplit_slstVerb3 = slstVerb3.split(',',2) - #Instantiate variable with new comma-separated list for readability - lstVerb3: List = StrSplit_slstVerb3 - - #Place ALL verbs entered into 1 list + # Place ALL verbs entered into 1 list via list concatenation lstAllVerbsEntered = lstVerb1 + lstVerb2 + lstVerb3 -#Obtain user's mutiple noun entries, and form list for indexing later +# Obtain user's mutiple noun entries, and form list for indexing later lstNoun1 = [input(sNounPrompt1)] lstNoun2 = [input(sNounPrompt2)] lstNoun3 = [input(sNounPrompt3)] @@ -63,24 +44,22 @@ def Main(): # Place ALL nouns entered into 1 list lstAllNounsEntered = lstNoun1 + lstNoun2 + lstNoun3 + lstNoun4 -#test input structure. comment all below entries out from final output. +# test input structure. Comment all below entries out from final output. # print('\t* lstAdjsEntered = ', lstAllAdjsEntered) # print('\t* lstAllVerbsEntered = ', lstAllVerbsEntered) # print('\t* lstAllNounsEntered = ', lstAllNounsEntered) -#Final Mad Libs Output +# Final Mad Libs Output FinalPrompt = input(sFinalPrompt) -# sFinalOutPut: str = '\nWhen I was little, I was afraid of ' + lstAllNounsEntered[1] + '.' print('\nWhen I was little, I was afraid of {}.'.format(lstAllNounsEntered[1]), 'I found them to be simply {}.'.format(lstAllAdjsEntered[0]), '\nNone of my{} classmates could understand, and they'.format(lstAllAdjsEntered[1]), lstAllVerbsEntered[0], 'about it constantly.\nBut what can you expect from{}'.format(lstAllAdjsEntered[1]), - 'people?\nNowadays, I cope by {}'.format(lstAllVerbsEntered[2]), 'loudly and{} {}'.format(lstAllVerbsEntered[3], + 'people?\n\nNowadays, I cope by {}'.format(lstAllVerbsEntered[2]), 'loudly and{} {}'.format(lstAllVerbsEntered[3], lstAllNounsEntered[2]), 'all around my {}.'.format(lstAllNounsEntered[3]), '\nIt’s surprisingly ' 'therapeutic! You wouldn’t think it would work since it sounds\nso{}.'.format(lstAllAdjsEntered[2]), 'I guess it just goes to show that even a(n){} {}'.format(lstAllAdjsEntered[3], lstAllNounsEntered[0]), 'can {},'.format(lstAllVerbsEntered[1]), 'too!' ) - Main() \ No newline at end of file From 180c3854959a92b7c64fbeb8eabfc9e79c2f5505 Mon Sep 17 00:00:00 2001 From: medioloquito <42821929+medioloquito@users.noreply.github.com> Date: Sun, 9 Sep 2018 22:42:36 -0400 Subject: [PATCH 07/20] Update MadLibs.py --- MadLibs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MadLibs.py b/MadLibs.py index d0ff2f4..381e726 100644 --- a/MadLibs.py +++ b/MadLibs.py @@ -1,4 +1,4 @@ -#Instantiate variables for use later +# Instantiate variables for use later sInitialPrompt = '\nPress ENTER to begin.' sAdjListPrompt = '\nEnter 4 adjectives, separated by commas: ' sVerbListPrompt1 = 'Enter a past tense verb: ' @@ -62,4 +62,4 @@ def Main(): 'I guess it just goes to show that even a(n){} {}'.format(lstAllAdjsEntered[3], lstAllNounsEntered[0]), 'can {},'.format(lstAllVerbsEntered[1]), 'too!' ) -Main() \ No newline at end of file +Main() From aa9249ca031e5402b47c9f4c70aea193b834d1b9 Mon Sep 17 00:00:00 2001 From: TJT Date: Wed, 12 Sep 2018 19:15:45 -0400 Subject: [PATCH 08/20] Ensuring version matching. No expexted changes. --- MadLibs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MadLibs.py b/MadLibs.py index d0ff2f4..60b8679 100644 --- a/MadLibs.py +++ b/MadLibs.py @@ -1,4 +1,4 @@ -#Instantiate variables for use later +# Instantiate variables for use later sInitialPrompt = '\nPress ENTER to begin.' sAdjListPrompt = '\nEnter 4 adjectives, separated by commas: ' sVerbListPrompt1 = 'Enter a past tense verb: ' From c735e2f0fef7bb57616340bc2009d8afb1686791 Mon Sep 17 00:00:00 2001 From: TJT Date: Wed, 12 Sep 2018 21:33:26 -0400 Subject: [PATCH 09/20] Commit message --- MadLibs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MadLibs.py b/MadLibs.py index 60b8679..f629941 100644 --- a/MadLibs.py +++ b/MadLibs.py @@ -51,7 +51,7 @@ def Main(): # Final Mad Libs Output FinalPrompt = input(sFinalPrompt) - +# Used .format to avoid inserting extra spaces between string and previously instantiated variables. print('\nWhen I was little, I was afraid of {}.'.format(lstAllNounsEntered[1]), 'I found them to be simply {}.'.format(lstAllAdjsEntered[0]), '\nNone of my{} classmates could understand, and they'.format(lstAllAdjsEntered[1]), From 5eb716bd32e57db3607599ff47782e108a119109 Mon Sep 17 00:00:00 2001 From: TJT Date: Tue, 25 Sep 2018 20:32:46 -0400 Subject: [PATCH 10/20] =?UTF-8?q?VimCrypt~01!=C2=B1=C2=BE=3F=C3=A4=1A'?= =?UTF-8?q?=CE=9Ca=06=C3=B4E=C2=A1=11=3D-{=D6=9C=1F=C3=81=C2=9A=C3=9B?= =?UTF-8?q?=C3=83=C3=BD=C2=A0=1AoV!=C2=A8=C3=9C=C3=A9s=C2=88=C3=84=0D?= =?UTF-8?q?=C2=9D=C3=B3]b=C2=9A=C3=92=C3=B0=C2=B5=C3=A0=C3=B3=C3=A6=C3=A4z?= =?UTF-8?q?=02=C3=AD=C3=BB=09J=C3=B5=C2=9D\$=D9=A2=C2=A7=C3=9CS=C3=87%i?= =?UTF-8?q?=C3=A2=20=C2=85{P=C2=92=C3=BDW=C3=B1=C2=9E=C3=8C=C3=AD=C2=B6F?= =?UTF-8?q?=C2=A9=C2=89U=C7=BF=C2=B5=C2=A9=13=C3=B1=08=C2=A3=C3=95=D5=B8?= =?UTF-8?q?=C3=80=C3=A3=C3=A0=C2=A6=12=C2=88=C3=96=C3=A1=C2=9Fs=0C=1BA?= =?UTF-8?q?=C2=89=C2=8FR=3D=C2=8F>=13=3D=07=C3=9B[T=5F=C2=90=C3=A5k=02?= =?UTF-8?q?=C2=90=C3=B7=C2=89f=C2=A4=C3=99=1E-=C3=A2=E3=8B=A0=08Q=C3=A8?= =?UTF-8?q?=C2=A0=C3=BE=D9=B3=C2=8C=C3=BE=C3=AD"=C2=BAQakFG=C3=80=C8=99?= =?UTF-8?q?=C3=80h=C3=B1M=CE=87=C2=BA'=C2=80=1A=C2=AB=E5=9E=B9h=C3=A8=02?= =?UTF-8?q?=18Z=C2=84>^=C2=B3g=C3=AA;=C2=A8=C2=85=0E=06=C6=80=C3=AE=14$GC?= =?UTF-8?q?=C3=98i`=C2=92=C2=8F=1F<=C2=98p=14=C3=9E=0EQ=C2=A69=F3=8A=9F=8B?= =?UTF-8?q?+=C2=B4=C2=99=C3=B0^=C6=9F=C2=B8=C3=B6=05=C2=BB=0Eck=C5=90?= =?UTF-8?q?=C2=B2=C2=B0=C3=B1=C2=8D=C3=93=C3=B8c^=C2=A1=C3=B5B=C2=A8@?= =?UTF-8?q?=C3=8ES=C3=BE=C3=9A=C3=A3=C2=BEF4=C2=A3=C2=9A=C3=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ForumGenerator.py | 288 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 ForumGenerator.py diff --git a/ForumGenerator.py b/ForumGenerator.py new file mode 100644 index 0000000..e80c4ca --- /dev/null +++ b/ForumGenerator.py @@ -0,0 +1,288 @@ +#Using to insert line breaks +import sys + +#Instantiate string variables +sStmt_initial = str('Who must use this form?:\n' +'\t1. Whether or not you have - W-2 Forms from all employers you (and your spouse,\n\t if filing a joint return) worked for during the past tax year.\n' +'\t2. Whether or not you have - 1099 Forms if you (or your spouse) completed contract\n\t work and earned more than $600.\n') +sStmt_non_monetary_values = str('\nGENERAL INFORMATION: \nPress ENTER after recording values for each prompt. If a given prompt does not apply, simply press ENTER to continue.\n\n' +'Press ENTER to begin inputting information related to yourself and your family.\n\n') +sStmt_monetary_values = str('\nENTER GENERAL INFORMATION:\nPress ENTER after recording exact monetary values for the prompts to follow.\n' +'If you have nothing to report for a given prompt, press ENTER to continue, and $0.00 will be recorded for you.\n\n' +'Press ENTER to begin.\n\n') +sFormEntryRecap_inc = 'Entries representing income:\n\n' +sFormEntryRecap_cred = 'Entries representing credits:\n\n' +sFormEntryRecap_gen_stmt = '\nPress enter to see a summary of your entries and to view your calculated tax or refund.\n\tIf you are entitled to a refund, follow prompts for delivery.\n\n' +sPrompt_SSN_personal = 'Your Social Security number without using hypens: ' +sPrompt_SSN_spouse = 'Your spouse’s Social Security number without hyphens (if married): ' +sPrompt_SSN_dependents = 'Social Security numbers for any dependents: ' +sPrompt_Invstmnt_inc = 'Investment income information (including: interest income, dividend income, proceeds from the sale of bonds or stocks, and income from foreign investments): ' +sPrompt_StateLocalTax_inc = 'Income from local and state tax refunds from the prior year: ' +sPrompt_Bus_inc = 'Business income (accounting records for any business that you own): ' +sPrompt_Unemp_inc = 'Unemployment income: ' +sPrompt_Rental_inc = 'Rental property income: ' +sPrompt_SS_inc = 'Social Security benefits: ' +sPrompt_Misc_inc = 'Miscellaneous income (including: jury duty, lottery and gambling winnings, Form 1099-MISC for prizes and awards, and Form 1099-MSA for distributions from medical savings accounts): ' +sPrompt_Homebuyer_cred = 'Homebuyer tax credit: ' +sPrompt_Energy_cred = 'Green energy credits: ' +sPrompt_IRA_cred = 'IRA contributions: ' +sPrompt_Mortgage_cred = 'Mortgage interest: ' +sPrompt_Student_cred = 'Student loan interest: ' +sPrompt_MedSavingsAcct_cred = 'Medical Savings Account (MSA) contributions: ' +sPrompt_SelfEmpHealthIns_cred = 'Self-employed health insurance: ' +sPrompt_Job_Moving_cred = 'Job and moving expenses: ' +#Moving expenses --- THIS SEEMS TO BE REPEAT +sPrompt_Education_cred = 'Education costs: ' +sPrompt_Childcare_cred = 'Childcare costs: ' +sPrompt_Adoption_cred = 'Adoption costs: ' +sPrompt_Contrib_cred = 'Charitable contributions/donations: ' +sPrompt_CasualtyTheft_cred = 'Casualty and theft losses: ' +sPrompt_QualBus_cred = 'Qualified business expenses: ' +sPrompt_MedExp_cred = 'Medical expenses: ' +#If a return is due +sPrompt_CheckOrDD = 'You will now be asked if you prefer having your refund sent via check sent or via direct deposit.\n' +sYNcheck = 'Do you prefer a check? Type Y or N and then press ENTER.\n' +sDDinfo = 'Please provide your bank information for direct deposit. Press ENTER after each entry.\n' +#If direct deposit is chosen, obtain bank information +sPrompt_BankAcctNum = 'Your bank account number: ' +sPrompt_BankRtgNum = 'The bank’s routing number: ' + +enteredNumReq = '\nYou must enter a number.\n' +incorrectPrecisionReq = 'Invalid monetary entry.\n' + +# Function returns 9 digit int after determining character length and reprompting for correct entry length +def is_nine_digits(sPromptVal,sInputVal,DesiredLength): + if sInputVal != '': + while int(len(sInputVal)) != int(DesiredLength): + sInputVal = input(sPromptVal + ' (Number should contain exactly {} characters): '.format(DesiredLength)) + return sInputVal + +# Function returns boolean, indicating whether an entry is an int datatype with a value greater than 0. +def is_int(sInputVal): + try: + int(sInputVal) > 0 + return True + except ValueError: + return False + +# Function returns boolean, indicating whether an entry is a float datatype with a value greater than 0. +def is_number(x): + try: + float(x) > 0 + return True + except ValueError: + return False + +# Function returns boolean, indicating whether float float precision is limited to two decimal spaces or less. +def precision_check(y): + if '.' not in str(y): + bCorrectPrecision = True + else: + lstValSplit: list = (str(y).split('.',2)) + decimalVal: str = lstValSplit[1] + lengthPrecision = len(decimalVal) + bCorrectPrecision = lengthPrecision < 3 + return bCorrectPrecision + +# Function returns string value, possibly +def money_val_str_output(z): + if '.' not in str(z): + z = str(z) + '.00' + else: + lstValSplit: list = (str(z).split('.',2)) + if len(lstValSplit[1]) == 1: + z = str(z) + '0' + elif len(lstValSplit[1]) == 2: + z = str(z) + return z + +# Function prompts users to enter proper monetary value before proceeding. Returns float value. +def num_entry_eval(sPromptVal,inputFltNumVal): + is_flt = is_number(inputFltNumVal) + is_correct_precision = precision_check(inputFltNumVal) + if is_flt is False or is_correct_precision is False or (is_flt is True and float(inputFltNumVal) <= int(0)) : + not_valid_entry = True + loopIncorrectValType: int = 0 + while not_valid_entry: + if loopIncorrectValType > int(0): + inputFltNumVal = input(sPromptVal) + is_correct_precision = precision_check(inputFltNumVal) + elif str(inputFltNumVal) == '': + not_valid_entry = False + else: + if is_correct_precision is False: + print(incorrectPrecisionReq) + loopIncorrectValType = loopIncorrectValType + 1 + else: + print(enteredNumReq) + loopIncorrectValType = loopIncorrectValType + 1 + if is_flt is True and float(inputFltNumVal) > int(0) and is_correct_precision is True: + not_valid_entry = False + if str(inputFltNumVal) == '': + inputFltNumVal = '0.0' + return float(inputFltNumVal) + +def main(): + # General, introductory statements + print(sStmt_initial) + input(sStmt_non_monetary_values) + + # SSN information + input_num_SSN_personal = input(sPrompt_SSN_personal) + num_SSN_personal = is_nine_digits(sPrompt_SSN_personal,input_num_SSN_personal,int(9)) + if str(input_num_SSN_personal) == '': + while input_num_SSN_personal == '': + input_num_SSN_personal = input(sPrompt_SSN_personal) + if str(input_num_SSN_personal) != '': + bNum_SSN_personal_is_int = is_int(input_num_SSN_personal) + if bNum_SSN_personal_is_int is False: + while bNum_SSN_personal_is_int is False: + input_num_SSN_personal = input(sPrompt_SSN_personal + ' (Number should contain exactly 9 characters): ') + bNum_SSN_personal_is_int = is_int(input_num_SSN_personal) + input_num_SSN_Spouse = input(sPrompt_SSN_spouse) + num_SSN_Spouse = is_nine_digits(sPrompt_SSN_spouse,input_num_SSN_Spouse,int(9)) + input_num_SSN_dependents = input(sPrompt_SSN_dependents) + num_SSN_dependents = is_nine_digits(sPrompt_SSN_dependents,input_num_SSN_dependents,int(9)) + if str(input_num_SSN_dependents) != '': + lst_num_SSN_dependents = () + while str(input_num_SSN_dependents) != '': + num_SSN_dependents = is_nine_digits(sPrompt_SSN_dependents,input_num_SSN_dependents,int(9)) + lst_num_SSN_dependents: list = (lst_num_SSN_dependents,num_SSN_dependents) + input_num_SSN_dependents = input(sPrompt_SSN_dependents) + + #obtain income source values below this line. Place into list, filling any blank spaces in with 0.0 + input(sStmt_monetary_values) + input_num_Invstmnt_inc = input(sPrompt_Invstmnt_inc) + num_Invstmnt_inc = num_entry_eval(sPrompt_Invstmnt_inc,input_num_Invstmnt_inc) + input_num_StateLocalTax_inc = input(sPrompt_StateLocalTax_inc) + num_StateLocalTax_inc = num_entry_eval(sPrompt_StateLocalTax_inc,input_num_StateLocalTax_inc) + input_num_Bus_inc = input(sPrompt_Bus_inc) + num_Bus_inc = num_entry_eval(sPrompt_Bus_inc,input_num_Bus_inc) + input_num_Unemp_inc = input(sPrompt_Unemp_inc) + num_Unemp_inc = num_entry_eval(sPrompt_Unemp_inc,input_num_Unemp_inc) + input_num_Rental_inc = input(sPrompt_Rental_inc) + num_Rental_inc = num_entry_eval(sPrompt_Rental_inc,input_num_Rental_inc) + input_num_SS_inc = input(sPrompt_SS_inc) + num_SS_inc = num_entry_eval(sPrompt_SS_inc,input_num_SS_inc) + input_num_Misc_inc = input(sPrompt_Misc_inc) + num_Misc_inc = num_entry_eval(sPrompt_Misc_inc,input_num_Misc_inc) + + total_combined_income: float = (num_Invstmnt_inc + num_StateLocalTax_inc + + num_Bus_inc + num_Unemp_inc + num_Rental_inc + num_SS_inc + + num_Misc_inc) + + #obtain tax source values below this line. Place into list, filling any blank spaces in with 0.0 + input_num_Homebuyer_cred = input(sPrompt_Homebuyer_cred) + num_Homebuyer_cred = num_entry_eval(sPrompt_Homebuyer_cred,input_num_Homebuyer_cred) + input_num_Energy_cred = input(sPrompt_Energy_cred) + num_Energy_cred =num_entry_eval(sPrompt_Energy_cred,input_num_Energy_cred) + input_num_IRA_cred = input(sPrompt_IRA_cred) + num_IRA_cred = num_entry_eval(sPrompt_IRA_cred,input_num_IRA_cred) + input_num_Mortgage_cred = input(sPrompt_Mortgage_cred) + num_Mortgage_cred = num_entry_eval(sPrompt_Mortgage_cred,input_num_Mortgage_cred) + input_num_Student_cred = input(sPrompt_Student_cred) + num_Student_cred = num_entry_eval(sPrompt_Student_cred,input_num_Student_cred) + input_num_MedSavingsAcct_cred = input(sPrompt_MedSavingsAcct_cred) + num_MedSavingsAcct_cred = num_entry_eval(sPrompt_MedSavingsAcct_cred,input_num_MedSavingsAcct_cred) + input_num_SelfEmpHealthIns_cred = input(sPrompt_SelfEmpHealthIns_cred) + num_SelfEmpHealthIns_cred = num_entry_eval(sPrompt_SelfEmpHealthIns_cred,input_num_SelfEmpHealthIns_cred) + input_num_Job_Moving_cred = input(sPrompt_Job_Moving_cred) + num_Job_Moving_cred = num_entry_eval(sPrompt_Job_Moving_cred,input_num_Job_Moving_cred) + input_num_Education_cred = input(sPrompt_Education_cred) + num_Education_cred = num_entry_eval(sPrompt_Education_cred,input_num_Education_cred) + input_num_Childcare_cred = input(sPrompt_Childcare_cred) + num_Childcare_cred = num_entry_eval(sPrompt_Childcare_cred,input_num_Childcare_cred) + input_num_Adoption_cred = input(sPrompt_Adoption_cred) + num_Adoption_cred = num_entry_eval(sPrompt_Adoption_cred,input_num_Adoption_cred) + input_num_Contrib_cred = input(sPrompt_Contrib_cred) + num_Contrib_cred = num_entry_eval(sPrompt_Contrib_cred,input_num_Contrib_cred) + input_num_CasualtyTheft_cred = input(sPrompt_CasualtyTheft_cred) + num_CasualtyTheft_cred = num_entry_eval(sPrompt_CasualtyTheft_cred,input_num_CasualtyTheft_cred) + input_num_QualBus_cred = input(sPrompt_QualBus_cred) + num_QualBus_cred = num_entry_eval(sPrompt_QualBus_cred,input_num_QualBus_cred) + input_num_MedExp_cred = input(sPrompt_MedExp_cred) + num_MedExp_cred = num_entry_eval(sPrompt_MedExp_cred,input_num_MedExp_cred) + + total_combined_credits: float = (num_Homebuyer_cred + num_Energy_cred + + num_IRA_cred + num_Mortgage_cred + num_Student_cred + num_MedSavingsAcct_cred + + num_Job_Moving_cred + num_Education_cred + num_Childcare_cred + num_SelfEmpHealthIns_cred + + num_Adoption_cred + num_Contrib_cred + num_CasualtyTheft_cred + num_QualBus_cred + + num_MedExp_cred) + + adjusted_income = total_combined_income - total_combined_credits + + input(sFormEntryRecap_gen_stmt) + + print(sFormEntryRecap_inc + + '\n'+ sPrompt_SSN_personal + str(num_SSN_personal) + + '\n'+ sPrompt_SSN_spouse + str(num_SSN_Spouse)) + for f in lst_num_SSN_dependents: + ssn = str(f) + print(sPrompt_SSN_dependents + ssn + '\n') + print(sPrompt_Invstmnt_inc + money_val_str_output(num_Invstmnt_inc) + + '\n' + sPrompt_StateLocalTax_inc + money_val_str_output(num_StateLocalTax_inc) + + '\n' + sPrompt_Bus_inc + money_val_str_output(num_Bus_inc) + + '\n' + sPrompt_Unemp_inc + money_val_str_output(num_Unemp_inc) + + '\n' + sPrompt_Rental_inc + money_val_str_output(num_Rental_inc) + + '\n' + sPrompt_SS_inc + money_val_str_output(num_SS_inc) + + '\n' + sPrompt_Misc_inc + money_val_str_output(num_Misc_inc) + + '\n' + sFormEntryRecap_cred + + sPrompt_Homebuyer_cred + money_val_str_output(num_Homebuyer_cred) + + '\n' + sPrompt_Energy_cred + money_val_str_output(num_Energy_cred) + + '\n' + sPrompt_IRA_cred + money_val_str_output(num_IRA_cred) + + '\n' + sPrompt_Mortgage_cred + money_val_str_output(num_Mortgage_cred) + + '\n' + sPrompt_Student_cred + money_val_str_output(num_Student_cred) + + '\n' + sPrompt_MedSavingsAcct_cred + money_val_str_output(num_MedSavingsAcct_cred) + + '\n' + sPrompt_SelfEmpHealthIns_cred + money_val_str_output(num_SelfEmpHealthIns_cred) + + '\n' + sPrompt_Job_Moving_cred + money_val_str_output(num_Job_Moving_cred) + + '\n' + sPrompt_Education_cred + money_val_str_output(num_Education_cred) + + '\n' + sPrompt_Childcare_cred + money_val_str_output(num_Childcare_cred) + + '\n' + sPrompt_Adoption_cred + money_val_str_output(num_Adoption_cred) + + '\n' + sPrompt_Contrib_cred + money_val_str_output(num_Contrib_cred) + + '\n' + sPrompt_CasualtyTheft_cred + money_val_str_output(num_CasualtyTheft_cred) + + '\n' + sPrompt_QualBus_cred + money_val_str_output(num_QualBus_cred) + + '\n' + sPrompt_MedExp_cred + money_val_str_output(num_MedExp_cred)) + + sAdjusted_income = money_val_str_output(adjusted_income) + print('\nYour adjusted Gross income = ${}'.format(sAdjusted_income)) + + if adjusted_income > int(0): + if adjusted_income >= int(0) and adjusted_income < int(13350): + income_tax_owed = round(adjusted_income**.1, 2) + elif adjusted_income >= int(13350) and adjusted_income < int(50800): + income_tax_owed = round(adjusted_income**.15, 2) + elif adjusted_income >= int(50800) and adjusted_income < int(131200): + income_tax_owed = round(adjusted_income**.25, 2) + elif adjusted_income >= int(131200) and adjusted_income < int(212500): + income_tax_owed = round(adjusted_income**.28, 2) + elif adjusted_income >= int(212500) and adjusted_income < int(416700): + income_tax_owed = round(adjusted_income**.33, 2) + elif adjusted_income >= int(416700) and adjusted_income < int(444550): + income_tax_owed = round(adjusted_income**.35, 2) + else: + income_tax_owed = round(adjusted_income**.396, 2) + print('\nThis is your taxable income: ${}'.format(adjusted_income) + + '\nYou owe us money!!! Send a check for ${}'.format(income_tax_owed)) + elif adjusted_income == int(0): + print('You neither owe taxes nor will receive a tax refund. Have a nice day!') + else: + print('You are eligible for a refund of ${}'.format(adjusted_income * -1)) + print(sPrompt_CheckOrDD) + yn_check = input(sYNcheck) + if str(yn_check) == 'N': + print(sDDinfo) + input_BankAcctNum = input(sPrompt_BankAcctNum) + num_BankAcctNum = is_number(input_BankAcctNum) + input_BankRtgNum = input(sPrompt_BankRtgNum) + num_BankRtgNum = is_number(input_BankRtgNum) + else: + print('You will receive your refund check by mail.') + + print('Thank your for using Forum Generator!') + +main() + + + + + From 964002deb59a059e439dc14288e14939e6c3b3df Mon Sep 17 00:00:00 2001 From: TJT Date: Tue, 25 Sep 2018 20:52:24 -0400 Subject: [PATCH 11/20] Added code deficiency comment at top of code to discuss with Nick --- ForumGenerator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ForumGenerator.py b/ForumGenerator.py index e80c4ca..cdb53cc 100644 --- a/ForumGenerator.py +++ b/ForumGenerator.py @@ -1,3 +1,5 @@ +#List splice of dependents SSN not working in form output. Discuss with Nick. + #Using to insert line breaks import sys From 373955788a0b2828cff59b8568e5238334127f13 Mon Sep 17 00:00:00 2001 From: TJT Date: Tue, 25 Sep 2018 21:49:28 -0400 Subject: [PATCH 12/20] Initial App Upload --- RandomNumberGame.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 RandomNumberGame.py diff --git a/RandomNumberGame.py b/RandomNumberGame.py new file mode 100644 index 0000000..7d1f58a --- /dev/null +++ b/RandomNumberGame.py @@ -0,0 +1,43 @@ +# import sys +import random + +initial_prompt = '\nPlease enter an integer between 1 & 100: ' +num_not_int = 'Entry is not an integer.\n' +wish_to_play = 'Y' + +# Function returns boolean, indicating whether an entry is an int datatype with a value greater than 0. +def is_int(sInputVal): + try: + int(sInputVal) > 0 + return True + except ValueError: + return False + +while wish_to_play == 'Y' or wish_to_play == 'y': + input('Welcome to The Random Number Guessing Game! Press ENTER to begin.\n') + random_num = random.randint(1, 100) # Integer from 1 to 100 + random_num = int(random_num) + # print (random_num) + num_input = input(initial_prompt) + bNum_input_is_int = is_int(num_input) + while num_input != random_num: + while bNum_input_is_int is False: + print(num_not_int) + num_input = input(initial_prompt) + bNum_input_is_int = is_int(num_input) + num_input = int(num_input) + if num_input < random_num: + print('Your guess is too low! Try again.\n') + num_input = input(initial_prompt) + elif num_input > random_num: + print('Your guess is too high! Try again.\n') + num_input = input(initial_prompt) + if num_input == random_num: + print('\nYou guessed correctly! Congratulations!') + wish_to_play = input('\nWould you would like to play again? (Type Y and press ENTER. (Or press ENTER to exit game.)): ') +print('\nThank you for playing The Random Number Guessing Game!') + + + + + From 2f34d21a0bcea1eca9a2a5f4beef471c5d1b5557 Mon Sep 17 00:00:00 2001 From: TJT Date: Tue, 25 Sep 2018 22:13:13 -0400 Subject: [PATCH 13/20] Simple output format update --- RandomNumberGame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RandomNumberGame.py b/RandomNumberGame.py index 7d1f58a..e274263 100644 --- a/RandomNumberGame.py +++ b/RandomNumberGame.py @@ -14,7 +14,7 @@ def is_int(sInputVal): return False while wish_to_play == 'Y' or wish_to_play == 'y': - input('Welcome to The Random Number Guessing Game! Press ENTER to begin.\n') + input('\nWelcome to The Random Number Guessing Game! Press ENTER to begin.\n') random_num = random.randint(1, 100) # Integer from 1 to 100 random_num = int(random_num) # print (random_num) From 9a190023db492e437f9072e2009cd1e2afed74fc Mon Sep 17 00:00:00 2001 From: TJT Date: Wed, 26 Sep 2018 10:23:30 -0400 Subject: [PATCH 14/20] Updated to include logic for range and number of attempts --- RandomNumberGame.py | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/RandomNumberGame.py b/RandomNumberGame.py index e274263..320d5ef 100644 --- a/RandomNumberGame.py +++ b/RandomNumberGame.py @@ -1,10 +1,19 @@ # import sys import random -initial_prompt = '\nPlease enter an integer between 1 & 100: ' -num_not_int = 'Entry is not an integer.\n' +# If want to change integer range, do so here. +int_range_start = 1 +int_range_stop = 100 + +# If want to change number of attempts allowed/remaining, do so here. +int_num_attempts_allowed = 10 + +initial_prompt = '\nPlease enter an integer between {} & {}: '.format(int_range_start,int_range_stop) +num_not_int = 'Entry is not an integer between {} & {}.\n'.format(int_range_start,int_range_stop) wish_to_play = 'Y' + + # Function returns boolean, indicating whether an entry is an int datatype with a value greater than 0. def is_int(sInputVal): try: @@ -14,27 +23,34 @@ def is_int(sInputVal): return False while wish_to_play == 'Y' or wish_to_play == 'y': - input('\nWelcome to The Random Number Guessing Game! Press ENTER to begin.\n') - random_num = random.randint(1, 100) # Integer from 1 to 100 + int_num_attempts_remaining = int_num_attempts_allowed - 1 + input('\nWelcome to The Random Number Guessing Game!' + '\nYou will have {} attempts to guess a number correctly.' + '\n**Press ENTER to begin.**\n'.format(int_num_attempts_allowed)) + random_num = random.randint(int_range_start, int_range_stop) # Obtain random number within integer range random_num = int(random_num) # print (random_num) num_input = input(initial_prompt) bNum_input_is_int = is_int(num_input) - while num_input != random_num: - while bNum_input_is_int is False: + while num_input != random_num and int_num_attempts_remaining != 0: + while bNum_input_is_int is False or int(num_input) < int_range_start or int(num_input) > int_range_stop: print(num_not_int) num_input = input(initial_prompt) bNum_input_is_int = is_int(num_input) + # while bNum_input_is_int is True and num_input != random_num: num_input = int(num_input) if num_input < random_num: - print('Your guess is too low! Try again.\n') + print('Your guess is too low! Try again. (You have {} attempts remaining)\n'.format(int_num_attempts_remaining)) num_input = input(initial_prompt) elif num_input > random_num: - print('Your guess is too high! Try again.\n') + print('Your guess is too high! Try again. (You have {} attempts remaining)\n'.format(int_num_attempts_remaining)) num_input = input(initial_prompt) - if num_input == random_num: + int_num_attempts_remaining = int_num_attempts_remaining - 1 + if int_num_attempts_remaining == 0: + print('You have run out of chances!\n') + elif num_input == random_num: print('\nYou guessed correctly! Congratulations!') - wish_to_play = input('\nWould you would like to play again? (Type Y and press ENTER. (Or press ENTER to exit game.)): ') + wish_to_play = input('\nWould you would like to play again? (Type Y and press ENTER. (Or press ENTER to exit game.)): ') print('\nThank you for playing The Random Number Guessing Game!') From ed4f135de4f5f80320ae887fa31fd696ed28fa1e Mon Sep 17 00:00:00 2001 From: TJT Date: Thu, 11 Oct 2018 18:23:32 -0400 Subject: [PATCH 15/20] Updated to correct loop list creation error --- ForumGenerator.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ForumGenerator.py b/ForumGenerator.py index cdb53cc..ed7bb75 100644 --- a/ForumGenerator.py +++ b/ForumGenerator.py @@ -146,12 +146,13 @@ def main(): input_num_SSN_dependents = input(sPrompt_SSN_dependents) num_SSN_dependents = is_nine_digits(sPrompt_SSN_dependents,input_num_SSN_dependents,int(9)) if str(input_num_SSN_dependents) != '': - lst_num_SSN_dependents = () + lst_num_SSN_dependents = list() while str(input_num_SSN_dependents) != '': num_SSN_dependents = is_nine_digits(sPrompt_SSN_dependents,input_num_SSN_dependents,int(9)) - lst_num_SSN_dependents: list = (lst_num_SSN_dependents,num_SSN_dependents) + num_SSN_dependents: list = input_num_SSN_dependents + lst_num_SSN_dependents.append(num_SSN_dependents) input_num_SSN_dependents = input(sPrompt_SSN_dependents) - + #obtain income source values below this line. Place into list, filling any blank spaces in with 0.0 input(sStmt_monetary_values) input_num_Invstmnt_inc = input(sPrompt_Invstmnt_inc) @@ -220,7 +221,8 @@ def main(): '\n'+ sPrompt_SSN_spouse + str(num_SSN_Spouse)) for f in lst_num_SSN_dependents: ssn = str(f) - print(sPrompt_SSN_dependents + ssn + '\n') + print(sPrompt_SSN_dependents + ssn) + sys.stdout.write('\n') print(sPrompt_Invstmnt_inc + money_val_str_output(num_Invstmnt_inc) + '\n' + sPrompt_StateLocalTax_inc + money_val_str_output(num_StateLocalTax_inc) + '\n' + sPrompt_Bus_inc + money_val_str_output(num_Bus_inc) + From 309d5d12d33d16530a70e8e6f626f1e12c654f0d Mon Sep 17 00:00:00 2001 From: TJT Date: Thu, 11 Oct 2018 18:45:54 -0400 Subject: [PATCH 16/20] Updated to reveal number if not guessed in alloted attempts. --- RandomNumberGame.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/RandomNumberGame.py b/RandomNumberGame.py index 320d5ef..0c4104f 100644 --- a/RandomNumberGame.py +++ b/RandomNumberGame.py @@ -3,10 +3,10 @@ # If want to change integer range, do so here. int_range_start = 1 -int_range_stop = 100 +int_range_stop = 10 # If want to change number of attempts allowed/remaining, do so here. -int_num_attempts_allowed = 10 +int_num_attempts_allowed = 3 initial_prompt = '\nPlease enter an integer between {} & {}: '.format(int_range_start,int_range_stop) num_not_int = 'Entry is not an integer between {} & {}.\n'.format(int_range_start,int_range_stop) @@ -32,25 +32,26 @@ def is_int(sInputVal): # print (random_num) num_input = input(initial_prompt) bNum_input_is_int = is_int(num_input) - while num_input != random_num and int_num_attempts_remaining != 0: - while bNum_input_is_int is False or int(num_input) < int_range_start or int(num_input) > int_range_stop: - print(num_not_int) - num_input = input(initial_prompt) - bNum_input_is_int = is_int(num_input) - # while bNum_input_is_int is True and num_input != random_num: - num_input = int(num_input) - if num_input < random_num: - print('Your guess is too low! Try again. (You have {} attempts remaining)\n'.format(int_num_attempts_remaining)) - num_input = input(initial_prompt) - elif num_input > random_num: - print('Your guess is too high! Try again. (You have {} attempts remaining)\n'.format(int_num_attempts_remaining)) - num_input = input(initial_prompt) + while num_input != random_num: + if int_num_attempts_remaining != 0: + while bNum_input_is_int is False or int(num_input) < int_range_start or int(num_input) > int_range_stop: + print(num_not_int) + num_input = input(initial_prompt) + bNum_input_is_int = is_int(num_input) + # while bNum_input_is_int is True and num_input != random_num: + num_input = int(num_input) + if num_input < random_num: + print('Your guess is too low! Try again. (You have {} attempts remaining)\n'.format(int_num_attempts_remaining)) + num_input = input(initial_prompt) + elif num_input > random_num: + print('Your guess is too high! Try again. (You have {} attempts remaining)\n'.format(int_num_attempts_remaining)) + num_input = input(initial_prompt) int_num_attempts_remaining = int_num_attempts_remaining - 1 - if int_num_attempts_remaining == 0: - print('You have run out of chances!\n') + if int_num_attempts_remaining == 0 and num_input != random_num: + print('You have run out of chances!\n*The correct answer was {}*'.format(random_num)) elif num_input == random_num: print('\nYou guessed correctly! Congratulations!') - wish_to_play = input('\nWould you would like to play again? (Type Y and press ENTER. (Or press ENTER to exit game.)): ') + wish_to_play = input('\nWould you would like to play again? (Type Y and press ENTER. Or press ENTER to exit game.): ') print('\nThank you for playing The Random Number Guessing Game!') From 88d4ce5f3c416177b61352eb161f56dec21d7fd6 Mon Sep 17 00:00:00 2001 From: TJT Date: Thu, 11 Oct 2018 18:52:47 -0400 Subject: [PATCH 17/20] Added comment at the top. --- MadLibs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MadLibs.py b/MadLibs.py index 64d75a9..b15dbc8 100644 --- a/MadLibs.py +++ b/MadLibs.py @@ -1,3 +1,5 @@ +#First Class Project + # Instantiate variables for use later sInitialPrompt = '\nPress ENTER to begin.' sAdjListPrompt = '\nEnter 4 adjectives, separated by commas: ' From 053bd17078343a85faff8851f90d0f59211fafd4 Mon Sep 17 00:00:00 2001 From: TJT Date: Fri, 12 Oct 2018 01:11:38 -0400 Subject: [PATCH 18/20] Initial upload of application. --- AddressBook.py | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 AddressBook.py diff --git a/AddressBook.py b/AddressBook.py new file mode 100644 index 0000000..9a61f9f --- /dev/null +++ b/AddressBook.py @@ -0,0 +1,90 @@ +##Address Book Program + +import sys + +sWelcomePrompt = ('Welcome to Little Black Book! This program will allow you to add' +'\nan unlimited number contacts and the associated information for each.' +'\nIf you do not want to enter anything for a given field, just press ENTER' +'\nor follow field-specific prompts.' +'\n\n**Press ENTER to begin entering your contact information!**\n') + +lb = '\n' +sName = 'Name: ' +sPhone = 'Phone Number: ' +sPhoneType = 'Enter "H" if this is a HOME number or W if this is a WORK number: ' +sEmail = 'Email Address' +sEmailType = 'Enter "H" if this is a HOME email or W if this is a WORK email: ' +sAddress = 'Physicial Address: ' +sBirthday = 'Brithday: ' +sNickname = 'Nickname(s): ' +sOccupation = 'Occupation: ' +sCompany = 'Company: ' +sAddMore = ('Your file has been updated.' +'\nIf you wish to add more contacts, enter "Y".' +'\nPress "N" to stop and view your contact list.' +'\nPress ENTER to exit the program: ') +lstTypes = ['H','h','W','w'] + +def homeVSwork(x,sInputVerbiage,sPrompt): + while x not in lstTypes: + x = input('Please enter a valid response.\n' + sPrompt) + if x == 'H' or x == 'h': + y = sInputVerbiage + ' (Home)' + elif x == 'W' or x == 'w': + y = sInputVerbiage + ' (Work)' + return(y) + +def Main(): + input_welcome = input(sWelcomePrompt) + #Throw this all into a While loop for as long as the user wants to add more entries + input_sAddMore = 'Y' + cntAddition = 0 + while input_sAddMore == 'Y' or input_sAddMore == 'y': + lb + lb + input_sName = input(sName) + input_sPhone = input(sPhone) + if input_sPhone != '': + input_sPhoneType = input(sPhoneType) + input_sPhone = homeVSwork(input_sPhoneType,input_sPhone,sPhoneType) + cntEmail = 1 + while cntEmail <= 2: + input_sEmail = input(sEmail + ' #{}: '.format(cntEmail)) + if cntEmail == 1: + input_1st_email = input_sEmail + cntEmail = cntEmail + 1 + input_2nd_email = '' + exists2ndEmail = False + if input_sEmail != '' and cntEmail == 3: + input_sEmailType = input(sEmailType) + input_2nd_email = homeVSwork(input_sEmailType,input_sEmail,sEmailType) + if input_2nd_email != '': + input_sEmail = str(' #1: ' + input_1st_email + lb + sEmail + ' #2: ' + input_2nd_email) + exists2ndEmail = True + if exists2ndEmail is False or input_2nd_email == '': + input_sEmail = input_1st_email + ':' + input_sAddress = input(sAddress) + input_sBirthday = input(sBirthday) + input_sNickname = input(sNickname) + input_sOccupation = input(sOccupation) + input_sCompany = input(sCompany) + fileInput = (sName + input_sName + lb + sPhone + input_sPhone + lb + + sEmail + input_sEmail + lb + sAddress + input_sAddress + lb + + sBirthday + input_sBirthday + lb + sNickname + input_sNickname + lb + + sOccupation + input_sOccupation + lb + sCompany + input_sCompany + lb) + if fileInput != '': + cntAddition = cntAddition + 1 + if cntAddition == 1: + f = open('AddressBook.txt','w+') + else: + f = open('AddressBook.txt','a') + for i in fileInput: + f.write(i) + f.close + input_sAddMore = input(sAddMore) + if input_sAddMore == 'N' or input_sAddMore == 'n': + r = open('AddressBook.txt','r') + content = r.read() + r.close() + print(content) +Main() From 9074069b478a75379faab12cd5f9ef85b3dc8ea1 Mon Sep 17 00:00:00 2001 From: TJT Date: Fri, 12 Oct 2018 09:33:49 -0400 Subject: [PATCH 19/20] Code refinements made --- AddressBook.py | 83 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/AddressBook.py b/AddressBook.py index 9a61f9f..a588cb1 100644 --- a/AddressBook.py +++ b/AddressBook.py @@ -2,6 +2,8 @@ import sys +filename = 'AddressBook.txt' + sWelcomePrompt = ('Welcome to Little Black Book! This program will allow you to add' '\nan unlimited number contacts and the associated information for each.' '\nIf you do not want to enter anything for a given field, just press ENTER' @@ -15,14 +17,14 @@ sEmail = 'Email Address' sEmailType = 'Enter "H" if this is a HOME email or W if this is a WORK email: ' sAddress = 'Physicial Address: ' -sBirthday = 'Brithday: ' +sBirthday = 'Birthday: ' sNickname = 'Nickname(s): ' sOccupation = 'Occupation: ' sCompany = 'Company: ' sAddMore = ('Your file has been updated.' -'\nIf you wish to add more contacts, enter "Y".' -'\nPress "N" to stop and view your contact list.' -'\nPress ENTER to exit the program: ') +'\nIf you wish to add more contacts, type "Y" and press ENTER.' +'\nType "N" and press ENTER to stop and view your contact list.' +'\nOr, simply press ENTER to exit the program.' + lb) lstTypes = ['H','h','W','w'] def homeVSwork(x,sInputVerbiage,sPrompt): @@ -34,35 +36,63 @@ def homeVSwork(x,sInputVerbiage,sPrompt): y = sInputVerbiage + ' (Work)' return(y) +def storeInput(filename,enteredValues,cntNumEntries): + if cntNumEntries == 1: + f = open(filename,'w+') + else: + f = open(filename,'a') + for i in enteredValues: + f.write(i) + f.close + +def getInput(filename,read): + fileOutput = open(filename,read) + print(fileOutput.read()) + fileOutput.close() + +def reqFld(x,sPrompt): + while x == '': + print('You must enter a value for this field.') + x = input(sPrompt) + return x + def Main(): - input_welcome = input(sWelcomePrompt) + input(sWelcomePrompt) #Throw this all into a While loop for as long as the user wants to add more entries input_sAddMore = 'Y' cntAddition = 0 while input_sAddMore == 'Y' or input_sAddMore == 'y': lb lb - input_sName = input(sName) + input_sName = reqFld(input(sName),sName) input_sPhone = input(sPhone) if input_sPhone != '': input_sPhoneType = input(sPhoneType) input_sPhone = homeVSwork(input_sPhoneType,input_sPhone,sPhoneType) - cntEmail = 1 + cntEmail = 1 + canEnterAdditionalEmail = True + input_2nd_email = '' + exists2ndEmail = False while cntEmail <= 2: - input_sEmail = input(sEmail + ' #{}: '.format(cntEmail)) - if cntEmail == 1: - input_1st_email = input_sEmail - cntEmail = cntEmail + 1 - input_2nd_email = '' - exists2ndEmail = False - if input_sEmail != '' and cntEmail == 3: - input_sEmailType = input(sEmailType) - input_2nd_email = homeVSwork(input_sEmailType,input_sEmail,sEmailType) + if canEnterAdditionalEmail is True: + input_sEmail = input(sEmail + ' #{}: '.format(cntEmail)) + input_1st_email = '' + if cntEmail == 1 and input_sEmail != '': + input_1st_email = input_sEmail + exists1stEmail = True + elif cntEmail == 1 and input_sEmail == '': + exists1stEmail = False + canEnterAdditionalEmail = False + if exists1stEmail is True and cntEmail == 2: + if input_sEmail != '': + input_sEmailType = input(sEmailType) + input_2nd_email = homeVSwork(input_sEmailType,input_sEmail,sEmailType) if input_2nd_email != '': - input_sEmail = str(' #1: ' + input_1st_email + lb + sEmail + ' #2: ' + input_2nd_email) + input_sEmail = (' #1: ' + input_1st_email + lb + sEmail + ' #2: ' + input_2nd_email) exists2ndEmail = True - if exists2ndEmail is False or input_2nd_email == '': + if exists1stEmail is True and (exists2ndEmail is False or input_2nd_email == ''): input_sEmail = input_1st_email + ':' + cntEmail = cntEmail + 1 input_sAddress = input(sAddress) input_sBirthday = input(sBirthday) input_sNickname = input(sNickname) @@ -71,20 +101,13 @@ def Main(): fileInput = (sName + input_sName + lb + sPhone + input_sPhone + lb + sEmail + input_sEmail + lb + sAddress + input_sAddress + lb + sBirthday + input_sBirthday + lb + sNickname + input_sNickname + lb + - sOccupation + input_sOccupation + lb + sCompany + input_sCompany + lb) + sOccupation + input_sOccupation + lb + sCompany + input_sCompany + lb + + '-----------------------------------------------------------' + lb) if fileInput != '': cntAddition = cntAddition + 1 - if cntAddition == 1: - f = open('AddressBook.txt','w+') - else: - f = open('AddressBook.txt','a') - for i in fileInput: - f.write(i) - f.close + storeInput(filename,fileInput,cntAddition) input_sAddMore = input(sAddMore) if input_sAddMore == 'N' or input_sAddMore == 'n': - r = open('AddressBook.txt','r') - content = r.read() - r.close() - print(content) + lb + getInput(filename,'r') Main() From 60c862c052c394bf278eda496760fac7df58916a Mon Sep 17 00:00:00 2001 From: TJT Date: Thu, 18 Oct 2018 22:41:57 -0400 Subject: [PATCH 20/20] Added additional logic for multiple phone entries --- AddressBook.py | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/AddressBook.py b/AddressBook.py index a588cb1..ac70e76 100644 --- a/AddressBook.py +++ b/AddressBook.py @@ -12,7 +12,7 @@ lb = '\n' sName = 'Name: ' -sPhone = 'Phone Number: ' +sPhone = 'Phone Number' sPhoneType = 'Enter "H" if this is a HOME number or W if this is a WORK number: ' sEmail = 'Email Address' sEmailType = 'Enter "H" if this is a HOME email or W if this is a WORK email: ' @@ -21,6 +21,7 @@ sNickname = 'Nickname(s): ' sOccupation = 'Occupation: ' sCompany = 'Company: ' +sSectionBreak = '-----------------------------------------------------------' sAddMore = ('Your file has been updated.' '\nIf you wish to add more contacts, type "Y" and press ENTER.' '\nType "N" and press ENTER to stop and view your contact list.' @@ -65,10 +66,28 @@ def Main(): lb lb input_sName = reqFld(input(sName),sName) - input_sPhone = input(sPhone) - if input_sPhone != '': - input_sPhoneType = input(sPhoneType) - input_sPhone = homeVSwork(input_sPhoneType,input_sPhone,sPhoneType) + input_sPhone = reqFld(input(sPhone + ': '),sPhone) + phoneNumLoopVar = 'x' + lstPhoneNumbers = list() + while phoneNumLoopVar != '': + if input_sPhone == '': + input_sPhone = input('Additional ' + sPhone + ' or press ENTER: ') + if input_sPhone != '': + input_sPhoneType = input(sPhoneType) + input_sPhone = homeVSwork(input_sPhoneType,input_sPhone,sPhoneType) + lstPhoneNumbers.append(input_sPhone) + phoneNumLoopVar = input_sPhone + input_sPhone = '' + sTmp = '' + length_lstPhoneNumbers = int(len(lstPhoneNumbers)) + cntPhone = 1 + for i in lstPhoneNumbers: + if cntPhone != length_lstPhoneNumbers: + sTmp = sTmp + sPhone + i + '\n' + else: + sTmp = sTmp + sPhone + i + cntPhone = cntPhone + 1 + input_sPhone = sTmp cntEmail = 1 canEnterAdditionalEmail = True input_2nd_email = '' @@ -101,8 +120,8 @@ def Main(): fileInput = (sName + input_sName + lb + sPhone + input_sPhone + lb + sEmail + input_sEmail + lb + sAddress + input_sAddress + lb + sBirthday + input_sBirthday + lb + sNickname + input_sNickname + lb + - sOccupation + input_sOccupation + lb + sCompany + input_sCompany + lb + - '-----------------------------------------------------------' + lb) + sOccupation + input_sOccupation + lb + sCompany + input_sCompany + lb + + sSectionBreak + lb) if fileInput != '': cntAddition = cntAddition + 1 storeInput(filename,fileInput,cntAddition)