For PYTHON:
In order to earn extra money, a student types extended essays for a fee. The amount charged depends on the number of pages in the document. The student charges:
$5 minimum fee for a document that is 1 to 3 pages in length
$1.50 per page for each page over 3 pages
An additional $3.75, if the number of pages exceeds 10
Assume that 200 words fit on a single typed page
For Example: A 1300 word essay would produce a fee of $11.00. 1300 / 200 = 6.5 actual pages, which rounds up to 7 pages. The fee the student will charge is $5 (for the first 3 pages) + ($1.50 x 4 pages), for a total of $11.00.
Create a Python program that will automatically calculate the fees based on the number of words in the essay.
Use the following test cases:
405 word essay will charge $5.00
624 word essay will charge $6.50
850 word essay will change $8.00
1000 word essay will charge $8.00
1100 word essay will change $9.50
1300 word essay will change $11.00
2425 word essay will change $23.75
The following python script can be used to implement the given problem :
def fun(words):
pages = words/200
if(pages - (int)(pages)) != 0:
pages = (int)(pages) + 1
if pages <= 3:
cost = 5.00
elif pages > 3 and pages <= 10:
cost = 5.00 + (pages - 3) * 1.50
else:
cost = 5.00 + (pages - 3) * 1.50 + 3.75
return cost
words = int(input("Enter the number of words : "))
print("\nThe cost of writing " + str(words) + " words is $" + str(fun(words)))
Please upvote the answer if you find it helpful.
Get Answers For Free
Most questions answered within 1 hours.