'''
filename: circleArea.py
This program asks the user to input a
number for the radius of a circle. The program
then calculates and output the area of the circle.
'''
import math
import sys
radius = float(input( "Enter radius in feet : " ))
area = math.pi * radius * radius
sys.stdout.write("The radius you provided was " + format(radius,'.2f') +
" feet and the area is about " + format(area,'.2f') + " sq feet" )
Write a function called computeArea() which will compute the area of a circle given the radius.
The function should receive the radius in a parameter list and return the computed area as the function returns value. A sample call to the function would be as follows:area = computeArea(radius)
Modify the program circleArea.py given above to make use of this function.
As an example, consider a $300 loan at 12% annual (i.e., 1% monthly) interest, which is being paid off at $100 per month.
After the first month, the balance is $200, but after interest, it increases to $202.
After the second month, the balance is $102, but after interest, it increases to $103.02.
After the third month, the balance is 3.02, which after interest increases to $3.05.
The remainder is paid off in the fourth month.
Write a Python program that prompts for the three parameters and conveys this information in a nice table. You can assume the loan will be paid off in less than five months. For example:
The loan amount is : 300 The annual interest rate is: 12 The monthly payment is: 100 Starting Middle Ending Month Balance Payment Balance Interest Balance ------------------------------------------------------- 1. 300.00 100.00 200.00 2.00 202.00 2. 202.00 100.00 102.00 1.02 103.02 3. 103.02 100.00 3.02 0.03 3.05 4. 3.05 3.05 0.00 0.00 0.00Run your program with the following 3 sets of sample data: 1)300 12 100
'''
filename:filep41.py
Read datafile1.dat in text format, create a list, print the
list to console and create a html table in output.html
'''
fileIn = open('datafile1.dat', 'r')
fileOut = open('output.html','w')
data=[]
lines = fileIn.read().splitlines()
for line in lines:
transactionRecord = line.split('_')
data.append(transactionRecord)
print('%-20s%-30s%5s%10s'%('Name','Address','Txn', 'Ampunt'))
print('='*65)
for e in data:
print('%-20s%-30s%5s%10s'%(e[0], e[1], e[2], e[3]))
fileOut.write('''
<table border=1>
<tr><th>Name</th><th>Address</th><th>Txn</th>Amount</th></tr>
''')
for e in data:
fileOut.write('<tr><td>'+e[0]+'</td>' +
'<td>'+e[1]+'</td>' +
'<td>'+e[2]+'</td>' +
'<td>'+e[3]+'</td>' + '</tr>')
fileOut.write('</table>')
fileIn.close()
fileOut.close()
Modify the program to output the table using markdown, upload output.md to github after you finished.