diff --git a/AddressBook.py b/AddressBook.py new file mode 100644 index 0000000..ac70e76 --- /dev/null +++ b/AddressBook.py @@ -0,0 +1,132 @@ +##Address Book Program + +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' +'\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 = 'Birthday: ' +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.' +'\nOr, simply press ENTER to exit the program.' + lb) +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 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(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 = reqFld(input(sName),sName) + 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 = '' + exists2ndEmail = False + while cntEmail <= 2: + 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 = (' #1: ' + input_1st_email + lb + sEmail + ' #2: ' + input_2nd_email) + exists2ndEmail = True + 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) + 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 + + sSectionBreak + lb) + if fileInput != '': + cntAddition = cntAddition + 1 + storeInput(filename,fileInput,cntAddition) + input_sAddMore = input(sAddMore) + if input_sAddMore == 'N' or input_sAddMore == 'n': + lb + getInput(filename,'r') +Main() diff --git a/ForumGenerator.py b/ForumGenerator.py new file mode 100644 index 0000000..ed7bb75 --- /dev/null +++ b/ForumGenerator.py @@ -0,0 +1,292 @@ +#List splice of dependents SSN not working in form output. Discuss with Nick. + +#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 = list() + while str(input_num_SSN_dependents) != '': + num_SSN_dependents = is_nine_digits(sPrompt_SSN_dependents,input_num_SSN_dependents,int(9)) + 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) + 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) + 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) + + '\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() + + + + + 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 diff --git a/MadLibs.py b/MadLibs.py new file mode 100644 index 0000000..b15dbc8 --- /dev/null +++ b/MadLibs.py @@ -0,0 +1,67 @@ +#First Class Project + +# 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!' + +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 + lstAllAdjsEntered: list = input(sAdjListPrompt).split(',',4) + +# Obtain user's mutiple verb entries, and form list for indexing later + lstVerb1 = [input(sVerbListPrompt1)] + + lstVerb2 = [input(sVerbListPrompt2)] + # Receive user input, parse into single items leveraging the "," and store in variable as a list. + lstVerb3: list = input(sVerbListPrompt3).split(',',2) + + # 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 + lstNoun1 = [input(sNounPrompt1)] + lstNoun2 = [input(sNounPrompt2)] + lstNoun3 = [input(sNounPrompt3)] + lstNoun4 = [input(sNounPrompt4)] + + # Place ALL nouns entered into 1 list + lstAllNounsEntered = lstNoun1 + lstNoun2 + lstNoun3 + lstNoun4 + +# 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) +# 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]), + lstAllVerbsEntered[0], 'about it constantly.\nBut what can you expect from{}'.format(lstAllAdjsEntered[1]), + '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() diff --git a/README.md b/README.md index af9ff9c..40a353c 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 Thomas} \ No newline at end of file diff --git a/RandomNumberGame.py b/RandomNumberGame.py new file mode 100644 index 0000000..0c4104f --- /dev/null +++ b/RandomNumberGame.py @@ -0,0 +1,60 @@ +# import sys +import random + +# If want to change integer range, do so here. +int_range_start = 1 +int_range_stop = 10 + +# If want to change number of attempts allowed/remaining, do so here. +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) +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': + 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: + 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 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.): ') +print('\nThank you for playing The Random Number Guessing Game!') + + + + +