Python Homework Help | Project | Python Assignment
Congratulations on getting an A, if that’s what you want to hear then we can help with python programming assignment.
An example of a Python programming homework help we can provide.
Python project Tax software
Problem:
Design a tax software organizing your logic into the 5 functions as described below.
getInputs()
This function will contain your code that prompts for inputs (gross pay,married?). It has no input arguments, and it returns two values: the gross pay entered and the number of exemptions.
getExemptionValue(exemptions)
This function will contain your logic for determining the exemption value. It takes the number of exemptions as input, and it returns the monetary value of the exemption.
getAdjustedGross(gross, exemptionValue)
This function will calculate the adjusted gross wage. It takes two parameters as input: gross pay and the exemptionValue. It will return the adjusted gross wage.
calculateTaxes(adjustedGross)
This function will calculate the individual taxes, as well as the net pay. It takes the adjustedGross as input, and returns the fica, medicare, federal tax, and net pay.
printResults(grossPay,fica,medicare,federalTax, net)
This function will print the results (same format as the earlier assignment). It takes the grossPay, fica, medicare, federalTax, and net as input parameters. It does not return any value — just prints the output.
Your main() function is the driver — it will call the other modules in the right order, with the right data, to accomplish the task. For example, the first part of your main would look like the following:
def main(): grossPay, exemptions = getInputs() exemptionValue = getExemptionValue(exemptions) adjustedGross = getAdjustedGross(grossPay,exemptionValue) #call Calculate taxes #call print results
program.py
def getInputs(): gross = float (input('Enter gross pay => ')) married = input('Are you married? Y/N => ') # input exemptions if married if married == 'Y': exemptions = int (input('Enter the number of exemptions => ')) else: # 1 for single exemptions = 1 return (gross, exemptions) def getExemptionValue(exemptions): if exemptions == 1: exvalue = 1000 elif exemptions == 2: exvalue = 1800 elif exemptions == 3: exvalue = 2400 elif exemptions == 4: exvalue = 3600 else: exvalue = 4000 return exvalue def getAdjustedGross(gross, exemptionValue): return gross - exemptionValue def calculateTaxes(adjustedGross): # calculate tax for the adjusted gross fica_tax = adjustedGross * 0.065 medi_tax = adjustedGross * 0.014 fede_tax = adjustedGross * 0.200 net_pay = adjustedGross - fica_tax - medi_tax - fede_tax return (fica_tax, medi_tax, fede_tax, net_pay) def printResults(grossPay, fica, medicare, federalTax, net): # print the tax and payment print () print ("PAYCHECK STUB") print (" Gross Pay: ${:>10.2f}".format (grossPay)) print (" FICA: ${:>10.2f}".format (fica)) print (" Medicare: ${:>10.2f}".format (medicare)) print ("Federal Tax: ${:>10.2f}".format (federalTax)) print ("-------------------") print (" Net Pay: ${:>10.2f}".format (net)) def main(): grossPay, exemptions = getInputs() exemptionValue = getExemptionValue(exemptions) adjustedGross = getAdjustedGross(grossPay,exemptionValue) #call calculate taxes fica, medi, fede, net = calculateTaxes(adjustedGross) #call print results printResults(grossPay, fica, medi, fede, net) if __name__ == '__main__': main()
Here is a sample of a Python programming project help, compare our results to your own work. Check out our python programming assignment help. We provide 100% plagarised free python programming assignment help.
Simple Python Functions
Problem:
For each function you will write code in main to test the function and convince yourself it works properly.
Each function description shows several examples of calling the function. Your func- tion should work properly with the arguments/input used in those examples and any other acceptable values (each function description gives the accepted type of value for each parameter and/or input).
If your function only works on the values shown in the examples it is wrong.
There are no specific requirements on what you should put in main to test each func- tion. It is fine to comment out the test code you have in main for functions you’ve already finished.
Create a new file called “conditions.py”. In the file write the following functions (10 points each):
1.) This function requires a bit of preparation first:
Try entering each of the following in a Python shell:
>>>len('mumps') 5 >>>len('elk') 3 >>>len('') 0 >>>phrase = 'That is silly!' >>>length = len(phrase) >>>print(length) 13
Using what you just learned about the len function, write a function called word_ length that has two parameters. The first will be a string and the second will be an integer. The function first prints a message about the relationship between the length of the word and the integer, as shown in the following examples:
Here are some examples of calling the function:
>>>word_length('liversnaps', 7) Longer than 7 characters: liversnaps >>>word_length('earwax', 5) Longer than 5 characters: earwax >>>word_length('chickenfat', 10) Exactly 10 characters: chickenfat >>>word_length('Gross!', 13) Shorter than 13 characters: Gross!
Write code in main to test this function. Don’t just test it on the arguments given in the examples. Test it on enough different values to convince yourself that it works properly.
2.) Write a function called stop_light that determines the color that a stop light should change to. It has two parameters. The first will either be “green”, “yellow”, or “red”. This represents the color that the stop light is currently showing. The second parameter is how long this color has been showing. If green has been showing longer than 60 seconds, print “yellow”. If yellow has been showing longer than 5 seconds, print “red”. If red has been showing longer than 55 seconds, print “green”. If the color hasn’t been showing long enough (e.g. green has been showing for 17 seconds), print the current color.
Here are some examples of calling the function:
>>>stop_light('green', 61) yellow >>>stop_light('yellow', 5) yellow >>>stop_light('yellow', 6) red >>>stop_light('red', 12) red >>>stop_light('red', 56) green
Write code in main to test this function. Don’t just test it on the arguments given in the examples. Test it on enough different values to convince yourself that it works properly.
3.) Write a function called is_normal_blood_pressure that has two integer parameters. The first represents systolic blood pressure (the top number in a blood pressure reading). The second represents diastolic blood pressure (the bottom number in a blood pressure reading). The function should return True if systolic is less than 120 AND diastolic is less than 80 (i.e. blood pressure is normal). Otherwise it returns False.
Here are some examples of calling the function:
>>>is_normal_blood_pressure(120, 80) False >>>is_normal_blood_pressure(119, 80) False >>>is_normal_blood_pressure(119, 79) True >>>is_normal_blood_pressure(120, 79) False
Write code in main to test this function. Don’t just test it on the arguments given in the examples. Test it on enough different values to convince yourself that it works properly.
4.) Write a function called doctor that has no parameters. The function will ask the user to enter his/her systolic blood pressure reading. It will then ask for the diastolic reading. The function then prints either “Your blood pressure is normal.” or “Your blood pressure is high.” depending on the values entered. This function should use the function you wrote in the previous question.
Here are some examples of calling the function:
>>>doctor() Enter your systolic reading: 119 Enter your diastolic reading: 79 Your blood pressure is normal. >>>doctor() Enter your systolic reading: 133 Enter your diastolic reading: 79 Your blood pressure is high.
Make sure you test the function on a variety of input. Don’t just test it on the values used in the examples. Test it on enough different values to convince yourself that it works properly.
5.) Write a function called pants size that has a single parameter (the value will be an integer) representing a person’s waist size in inches. The function returns a string. The string returned will be either “small”, “medium”, or “large” depending on the parameter value. Waist measurements that are 34 inches or larger shouldreturn large. Measurements that are 30 inches or larger, but not large enough to be in the large category, should return medium. Anything smaller should returnsmall.
Here are some examples of calling the function:
>>>pants_size(38) large >>>pants_size(34) large >>>pants_size(33) medium >>>pants_size(29) small >>>pants_size(-20) small >>>pants_size(2000) large
Write code in main to test this function. Don’t just test it on the arguments given in the examples. Test it on enough different values to convince yourself that it works properly.
6.) Write a function called pants_fitter that takes no arguments. The function should first ask the user for his/her name. It then greets the user by name. Next it asks the user for his/her waist size in inches (a positive integer). It then asks the user how many pairs of pants he/she would like to buy (a positive integer). Next it asks what type of pants the user wants to buy (either “regular” or “fancy”). Next it calculates the cost of the pants (integer). Regular pants cost \$40 per pair. Fancy pants cost \$100 per pair. Finally it prints out the number of pairs, the size, the type, and the total cost. The following examples show the format that your prompts and output should be in. This function should use the function you wrote in the previous question.
Here are some examples of calling the function:
>>>pants_fitter() Enter your name: Ziggy Greetings Ziggy welcome to Pants-R-Us Enter your waist size in inches: 34 How many pairs of pants would you like? 2 Would you like regular or fancy pants? fancy 2 pairs of large fancy pants: $ 200 >>>pants_fitter() Enter your name: Elmer Greetings Elmer welcome to Pants-R-Us Enter your waist size in inches: 31 How many pairs of pants would you like? 10 Would you like regular or fancy pants? regular 10 pairs of medium regular pants: $400 >>>pants_fitter() Enter your name: Minnie Greetings Minnie welcome to Pants-R-Us Enter your waist size in inches: 12 How many pairs of pants would you like? 1 Would you like regular or fancy pants? fancy 1 pairs of small fancy pants: $100
Make sure you test the function on a variety of input. Don’t just test it on the values used in the examples. Test it on enough different values to convince yourself that it works properly.
7.) Write a function called digdug that takes a single argument number (assume it will always be a positive integer). For every integer from 1 up to and including number, the function will print a message. If the integer is evenly divisible by 3 the function will print “dig”. If the integer is evenly divisible by 5 it prints “dug”. If the integer is evenly divisible by both 3 and 5 it prints “digdug”. If the integer is not divisible by either 3 or 5 it does not print anything.
Here are some examples of calling the function:
>>>digdug(1) >>>digdug(2) >>>digdug(3) 3 : dig >>>digdug(5) 3 : dig 5 : dug >>>digdug(15) 3 : dig 5 : dug 6 : dig 9 : dig 10 : dug 12 : dig 15 : digdug
Write code in main to test this function. Don’t just test it on the arguments given in the examples. Test it on enough different values to convince yourself that it works properly.
8.) Write a function called beef_type that takes a single parameter percent_lean. If the value of percent_lean is between 0-78% then return “Hamburger”. If it is between 78-85 percent, then return “Chuck”. Between 85-90 percent return “Round”. Between 90-95 percent should return “Sirloin”. If percent_lean doesn’t fall within one of these ranges, return “Unknown”. If percent_lean is right on the boundary, put it in the higher category.
Here are some examples of calling the function:
>>>beef_type(91.2) Sirloin >>>beef_type(78.0) Chuck >>>beef_type(87) Round >>>beef_type(95.1) Unknown
Write code in main to test this function. Don’t just test it on the arguments given in the examples. Test it on enough different values to convince yourself that it works properly.
9.) Write a function called species_height that takes 2 arguments. The first is either “Human” or “Klingon”. The second is a positive float representing the height (in inches) of this human or Klingon. In this homework assignment, the average human height is 67 inches. The average Klingon height is 71 inches. For the parameters given, print out if it is above, below or at the average height for its species.
Here are some examples of calling the function:
>>>species_height('Human', 62.1) Below Average >>>species_height('Klingon', 73) Above Average >>>species_height('Klingon', 71) Average
Write code in main to test this function. Don’t just test it on the arguments given in the examples. Test it on enough different values to convince yourself that it works properly.
10.) Write a function called sooner_date that has 4 integer parameters. The first is a number between 1 and 12 (inclusive) that represents a month. 1 is January, 2 is February, etc. The second is a number between 1 and 31 (inclusive) that represents a day. The third parameter is another integer representing a month and the fourth is another integer parameter representing a day. So essentially you have 2 dates (the first 2 parameters and the second 2 parameters). Figure out which date would come sooner, then print out that date in the format month / day.
Here are some examples of calling the function:
>>>sooner_date(1, 1, 1, 2) 1 / 1 >>>sooner_date(2, 5, 1, 3) 1 / 3 >>>sooner_date(8, 25, 7, 30) 7 / 30
Write code in main to test this function. Don’t just test it on the arguments given in the examples. Test it on enough different values to convince yourself that it works properly.
template.py
''' Author: <your name> Date: <the date> Class: ISTA 130 Section Leader: <your section leader> Description: <summary of this program> ''' # put all of your import statements below this line and then delete this comment # put all of your function definitions below this line and then delete this comment def word_length(string, n): if len(string) > n: print ('Longer than %d characters: %s' % (n, string)) elif len(string) < n: print ('Shorter than %d characters: %s' % (n, string)) else: print ('Exactly %d characters: %s' % (n, string)) def stop_light(color, time): if color is 'green' and time > 60: print ('yellow') elif color is 'yellow' and time > 5: print ('red') elif color is 'red' and time > 55: print ('green') else: print (color) def is_normal_blood_pressure(systolic, diastolic): return systolic < 120 and diastolic < 80 def doctor(): systolic = float (input ('Enter your systolic reading: ')) diastolic = float (input ('Enter your diastolic reading: ')) if is_normal_blood_pressure(systolic, diastolic): print ('Your blood pressure is normal.') else: print ('Your blood pressure is high.') def pants_size(waist): if waist >= 34: return "large" if waist >= 30: return "medium" return "small" def pants_fitter(): name = input ('Enter your name: ') print ('Greetings %s welcome to Pants-R-Us' % (name)) waist = int (input ('Enter your waist size in inches: ')) n = int (input('How many pairs of pants would you like? ')) r = input ('Would you like regular or fancy pants? ') print ('%d pairs of %s %s pants: $%d' % (n, pants_size(waist), r, n * 100 if r == 'fancy' else n * 40)) def digdug(number): i = 1 while i <= number: if i % 3 == 0 and i % 5 == 0: print ('%d: digdug' % (i)) elif i % 3 == 0: print ('%d: dig' % (i)) elif i % 5 == 0: print ('%d: dug' % (i)) i += 1 def beef_type (percent_lean): if percent_lean < 78: return ('Hamberger') elif percent_lean < 85: return ('Chuck') elif percent_lean < 90: return ('Round') elif percent_lean < 95: return 'Sirloin' return 'Unknown' def species_height(specy, height): avg = 67 if specy == 'Human' else 71 if height < avg: print ('Below Average') elif height == avg: print ('Average') else: print ('Above Average') def sooner_date(month1, day1, month2, day2): if month1 < month2 or (month1 == month2 and day1 <= day2): print ('%d / %d' % (month1, day1)) elif month1 > month2 or (month1 == month2 and day1 >= day2): print ('%d / %d' % (month2, day2)) #========================================================== def main(): ''' Write a description of what happens when you run this file here. ''' # put main code here, make sure each line is indented one level, and delete this comment word_length('hello', 1) word_length('hello', 5) word_length('hello', 7) stop_light('green', 61) stop_light('yellow', 5) stop_light('yellow', 6) stop_light('red', 12) stop_light('red', 56) stop_light('green', 60) print (is_normal_blood_pressure(120, 80)) print (is_normal_blood_pressure(110, 70)) print (is_normal_blood_pressure(110, 80)) print (is_normal_blood_pressure(120, 70)) doctor() print (pants_size(38)) print (pants_size(34)) print (pants_size(32)) print (pants_size(28)) pants_fitter() digdug(20) print (beef_type(91.2)) print (beef_type(78)) print (beef_type(87)) print (beef_type(95.1)) print (beef_type(0)) species_height('Human', 62.1) species_height('Kingon', 73) species_height('Kingon', 71) species_height('Kingon', 69) sooner_date (1, 1, 1, 2) sooner_date (2, 5, 1, 3) sooner_date (8, 25, 7, 30) sooner_date (8, 25, 8, 25) input('Press enter to end.') # keeps the turtle graphics window open if __name__ == '__main__': main()
For all your Python programming homework help, we offer the answer to your Python problems. If you need online python programming project help you are at the right place.
Python Programming Project Help
Pay As You Go (PAYG) Tax Return Calculation for year 2014
Problem:
A local accountant in your suburb has requested you to develop a python program that will allow him to provide basic tax return advice to his clients. The program should allow an individual to assess his income, expenses and tax payable in 2014 based on the following information.
Firstly, the program should have a function called calculateTotalIncome() that will prompt the user to enter the client’s taxable incomes (ex: salary1, salary2, additional income, income from shares, in come from properties, etc.) as follows:
Enter the income amount $:
The calculateTotalIncome() function will prompt the user to enter the client’s incomes until the user enters a negative value as the income amount. Once, the user finishes entering the taxable incomes, the calculateTotalIncome () function should then return the total income to the main program.
Secondly, the program should have a function called calculateTotalExpense() that will prompt the user to enter the client’s tax deductable expense details as follows:
Enter the expense amount $:
The calculateTotalExpense() function will prompt the user to enter the client’s expenses until the user enters a negative value as the expense amount. Once, the user finishes entering the expenses, the calculateTotalExpense() function should then return the totalexpenses to the main program.
Thirdly, the main program should calculate the net income as the difference between the total income and total expenses for the year 2014. After that, the program pass the net income as an argument to another function called calculateAnnualTax() that calculates the tax payable based on the table given below and returns tax payable to the main program.
The Australian Tax Office (ATO -https://www.ato.gov.au/Individuals/Income-and-deductions/How-much-income-tax-you-pay/Individual-income-tax-rates/ – retrieved on 1st May 2014) has announced this information for the individual tax returns in 2014.
Taxable income | Tax on this income |
---|---|
0 – $18,200 | Nil |
Above $18,200 – $37,000 | 19c for each $1 over $18,200 |
Above $37,000 – $80,000 | $3,572 PLUS 32.5c for each $1 over $37,000 |
Above $80,000 – $180,000 | $17,547 PLUS 37c for each $1 over $80,000 |
Above $180,000 | $54,547 PLUS 45c for each $1 over $180,000 |
Finally, the main program should display the information such as total income, total expenses, net income, and tax payable for the client. Note: You should not consider other detailed taxation details.
After display the information of a client, the program should prompt the user with the following message “Do you want to calculate tax return for another client? [Y/N]: “. If the user enters “Y” then the whole process will be repeated for another client. The program quits otherwise.
Use multiple functions, instead of using a single function to do everything. Create a good design of the functions to make the best use of the code and avoid duplicate calculations. You also need to design your program so that it has components that can be reused in another program, if needed.
Write an algorithm in structured English (pseudocode) that describes the steps required to perform the task specified. Some examples of pseudocode can be found at
http://www.unf.edu/\~broggio/cop2221/2221pseu.htm
Implement your algorithm in Python.
Avoid duplicate code.
Comment your code as necessary to explain it clearly.
Select 3 sets of test data that will demonstrate the correct “normal” operation of your program.
Run your program using the test data you have selected and save the output it produces in a text file.
Solution
1. Algorithm
Since inputting both income and expense requires the similar functionality (just the labels are different), define a function calculateTotalAmount to do the work:
Function calculateTotalAmount(label)
- Let total amount = 0
- While True
- Display the label and ask user to input a new amount
- Convert the new amount to a float number
- If the amount is negative, break the while loop
- Otherwise, total amount = total amount + new amount
- Return total amount
The calculateAnnualTax function calculates the tax payable according to the net income.
Function calculateAnnualTax(net income):
- If net income <= 18200: return 0 as the tax
- If net income <= 37000: return (net income – 18200) * 0.19 as the tax
- If net income <= 80000: return 3572 + (net income – 37000) * 0.325 as the tax
- If net income <=180000: return 17547 + (net income – 80000) * 0.37 as the tax
- Otherwise, return 54547 + (net income – 180000) * 0.45 as the tax.
In the main function, a while loop is implemented and the loop quits only if the user does not input capital ‘Y’ to continue for the next tax return.
Function main()
- While True
- Call calculateTotalIncome to get the total income
- Call calculateTotalExpense to get the total expense
- Net income = total income – total expense
- Call calculateAnnualTax to calculate the tax payable
- Display total income, total expense, net income and tax payable
- Display the label and ask the user to input ‘Y’ to continue
- If the input is not ‘Y’, quit the while loop.
2. Test data
Test 1 | 10000 |
20000 | |
-1 | |
10000 | |
5000 | |
-1 | |
N | |
Test 2 | 100000 |
200000 | |
-1 | |
50000 | |
40000 | |
10000 | |
0 | |
-1 | |
N | |
Test 3 | 10000 |
20000 | |
30000 | |
-1 | |
10000 | |
5000 | |
7000 | |
-1 | |
Y | |
100000 | |
-1 | |
10000 | |
-2 | |
N |
Test1: a normal case that results in no tax payable
Test2: a normal case that has total net income 200000, which checks all IF cases in the calculateAnnualTax function.
Test3: a normal case that input ‘Y’ to continue calculating tax for the next client. And two clients have net income 38000 and 90000, respectively.
3. Source code
Source code is in assign3.py file.
assign3.py
# enter total amount for (income or expense) # until a negative is input # then return the total amount def calculateTotalAmount(label): total = 0 while True: value = input('Enter the %s amount $: ' % (label)) # convert the value to a float number try: value = float(value) except ValueError: print ('Error: invalid income.') continue if value < 0: # a negative value break # add to the total income total += value return total # enter incomes until a negative value is input # return the total income def calculateTotalIncome(): return calculateTotalAmount('income') # enter expenses until a negative value is input # return the total expense def calculateTotalExpense(): return calculateTotalAmount('expense') # calculate the annual tax for the net income def calculateAnnualTax(taxableIncome): if taxableIncome <= 18200: return 0 if taxableIncome <= 37000: return (taxableIncome - 18200) * 0.19 if taxableIncome <= 80000: return 3572 + (taxableIncome - 37000) * 0.325 if taxableIncome <= 180000: return 17547 + (taxableIncome - 80000) * 0.37 return 54547 + (taxableIncome - 180000) * 0.45 def main(): while True: totalIncome = calculateTotalIncome() totalExpense = calculateTotalExpense() netIncome = totalIncome - totalExpense tax = calculateAnnualTax(netIncome) print ("Total Income :", totalIncome) print ("Total Expense:", totalExpense) print ("Net Income :", netIncome) print ("Tax payable :", tax) c = input ("Do you want to calculate tax return for another client? [Y/N]: ") # quit if not 'Y' if c != 'Y': break main()
4. Test result
Outputs are saved into file output_t1.txt, output_t2.txt, output_t3.txt, respectively.
If you need expert python programming tutors or help with Python programming assignment like this, you’re welcome to Contact us.
Count common words
Problem:
You are asked to implement two functions and save them in a file named “assignment1.py”. Please note that you MUST name you file as given or you won’t be able to run the test cases.
The first function should be named “maxParagraphLength” with the following signature:
maxParagraphLength (paragraphs)
This parameter “paragraphs” is a list of lists of strings. Conceptually, this parameter represents the contents of a book. Each element in the list is a list of string, and represents a paragraph in the book. The strings in each of this list represent the words in the paragraph.
The implementation of “maxParagraphLength” should be similar to the “maxLength” function we will learn in Chapter 5, but instead of returning the string having the largest length, your function should return the integer that represents this largest length itself. When passing “paragraphs” as the argument to this function, it should tell us how many words the longest paragraph contains.
The second function should be named “countParagraphsWithCommonWords”, and have the following signature:
countParagraphWithCommonWords (paragraphs, common, howmany)
The first parameter is exactly the one used in “maxParagraphLength”; the second is a list of strings representing a list of common words used in the book; and the last parameter is an integer. This function should return the number of paragraphs that contains at least “howmany” words (including repeats) appear in “commons”.
To test your functions, download the three files, “pg1.py”, “pg1260.py”, and “a1tester.py”; and save them in the same folder as your assignment file. The file “pg1.py” contains all the words from “The Declaration of Independence of the United States of America” by Thomas Jefferson. The file “pg1260.py” contains all the words from “Jane Eyre” by Charlotte Brontë. Both documents are freely available on the Internet. The file “a1tester.py” is a tester program that allows you to test your implementation.
If your implementation of the function is correct, running the tester program should produce the following output:
Testcase 1 started ... Test 1 passed. Test 2 passed. Test 3 passed. Test 4 passed. Test 5 passed. Test 6 passed. Test 7 passed. Test 8 passed. Test 9 passed. Test 10 passed. Test 11 passed. Test 12 passed. Test 13 passed. Test 14 passed. Test 15 passed. Test 16 passed. Test 17 passed. Test 18 passed. Test 19 passed. Test 20 passed. Test 21 passed. Test 22 passed. Test 23 passed. Test 24 passed. Test 25 passed. Testcase 1 finished - score = 25 of 25 Testcase 2 started ... Test 1 passed. Test 2 passed. Test 3 passed. Test 4 passed. Test 5 passed. Test 6 passed. Test 7 passed. Test 8 passed. Test 9 passed. Test 10 passed. Test 11 passed. Test 12 passed. Test 13 passed. Test 14 passed. Test 15 passed. Test 16 passed. Test 17 passed. Test 18 passed. Test 19 passed. Test 20 passed. Test 21 passed. Test 22 passed. Test 23 passed. Test 24 passed. Test 25 passed. Testcase 2 finished - score = 25 of 25
assignment1.py
# return the number of words in the longest paragraph def maxParagraphLength(paragraphs): maxLen = 0 # traverse all paragraphs for paragraph in paragraphs: # if this paragraph has more words, # update the longest paragraph if maxLen < len(paragraph): maxLen = len(paragraph) return maxLen # return the number of paragraphs, # each of which contains at least (howmany) words from (common) list # (including repeats) def countParagraphsWithCommonWords(paragraphs, common, howmany): count = 0 # traverse all paragraphs for paragraph in paragraphs: # initialize the number of common words in this paragraph to 0 num = 0 # traverse all words in this graph # increase num if any word is in the common list for word in paragraph: if word in common: num = num + 1 # if the number of common words is at least howmany # increase the number of satisfied paragraphs if num >= howmany: count = count + 1 return count
Our experts provide help with python programming homework if after the project is delivered. They provide help with python programming homework in the easiest way possible. After looking at the kind of Python programming assignment help, feel free to contact us.