In: Computer Science
Background
Hands-On Assignments are designed to foster independent thinking and problem solving programming skills. This activity is closely guided by the course instructor. Students are encourages to ask instructor any questions related to this challenge. Similar to the course Exercises, this activity also has a Base Code.
The initially given Base Code to Start with this assignment:
This assignment is based on the project 6.9 of the course book.
--------------Start----------------
buttondemo.py
breezypythongui.py
--------------End ----------------
---------------------------------------
Prompt
Task to Accomplish
The Base Code opens a window with label and two buttons. You will need to add:
How to proceed:
Submission
Submit both Screenshot image and your modified Python program.
Base code runs without any errors as long as the input file is in the same directory as that of the code's.
Modify input text file as per the requirement.
Input fiile
Lambert 34 10.50 1234 Chicago
Osborne 22 6.25 1235 Washington
Giacometti 5 100.70 1236 Newyork
fileName = input("Enter the input file name: ") inputFile = open(fileName,'r') #add two new fields for output header.(Choose the size of fields that looks good.I chose 20s and 15s) print("%.15s%15s%15s%20s%15s"%("Name","Hours","Total Pay","Employee Number","Address")) for line in inputFile: dataList = line.split() name = dataList[0] hours = int(dataList[1]) payRate = float(dataList[2]) totalPay = hours*payRate print("%.15s%10d%15.2f%15s%20s"%(name,hours,totalPay,dataList[3],dataList[4])) #dataList[3] will contain Employee Number and dataList[4] will contain Address.So, I used them in print with out any variable assignment.
CODE SS
There are some pre written modules ( like pretty table) that help in better formatting of the output. (In case you feel that output isn't pretty).