LINA KAVAL



Lina Kaval / M12984887 / kavalla@mail.uc.eduIntroductionDescriptionI made a grade calculator for my Calculus class. Currently, I am not able to calculate my math grade. Because my math online textbook, Webassign, is not connected to Blackboard, I do not have a way to view my grade quickly. Therefore, in order to calculate my grade for the class, I must tally up all the total points from about 70 assignments, as well as add the weighted points from my 3 midterms and final. Therefore, my program will use the html file downloaded to get the scores, get it into number format to calculate the average, as well as prompt the user for midterm and final scores to calculate the overall score for my Calculus class.OverviewFirst, I needed to download the webpage with my homework assignments, as it would require me to login if I tried getting the content straight from the webpage. Second, using lxml, I took the html and converted it into a list. The objects in this list were objects of lxml.etree so they had to be converted into strings so that I could use them. The bulk of the work was centered around getting the scores into a calculable state. At first, because I hadn’t accounted for the objects in the list being of type lxml.etree, I tried comparing the items in the list with strings to get the scores, which did not work. After trying to troubleshoot for hours, I finally realized my mistake.In order to see if my code had successfully calculated the average score, I pretended that the homework grades and practice grades were weighted the same. After that, I had to separate the practice values from the homework values. Once the values were calculated, I prompted the user for the test scores and applied the weight outlined in the syllabus of my calculus class. Finally, the overall class score is outputted.Since my program is displayed on the python shell, it is readable but may not be considered “user-friendly.” If I had more knowledge and time, I could try to make the program look more like a Windows Form Application, which is easier for users to use.Because I hardcoded many of the weight values, only people taking calculus and using Webassign for homework at UC would be able to use my program to figure out their score. If I had more time to work on this project, I would try to have my program also read the weighted values on a syllabus html file so that different weight values could be used instead. My goal is to try to minimize the number of inputs the user would be required to do.(Flowchart on the next page) Project ResultsThe tutorial that showed me how to use lxml was simple but helped me understand what file types items were saved as. The tutorial used an html that had a simple layout, with the text in a specific type of content box. However, when I inspected the page, because of the way the Webassign website is created (it’s not very good), there was no easy way to only get the scores, as the scores were in a content box, in a content box, in a content box. Therefore, the scoreList variable starts with some extraneous content that I later filtered.In my first iteration of the filtering code to get only the scores, it took me a couple hours. At first, I used a for loop to check for whether the string within the scoreList had “Score: ”. However, it did not like that, I got the exact opposite result, filtering all the scores and getting everything else instead. It may have had to do with me not realizing the items in the list were not in the strings, or it didn’t like me removing the score inside the for loop.Eventually, I ended up using a while loop, which worked well for the code that followed, where I had to clean the individual strings.If a score for a homework assignment is 0, the html page did not show how many total points were in that assignment, requiring manual input from the user. Therefore, while it is trying to add the scores to the list, if it came across a 0, I prompted the user for the total point value.However, in order to separate the homework points from the practice points, which are weighted differently, I simply created new lists to add the values to, instead of removing from the main list. This meant I could loop once and not worry about index values from removing items.Then I made my individual string cleaning code into a function so that I could call it on both the homework and practice lists. After that, I prompted the user for values for the midterm and final grades, which were then calculated into a final grade. Resources I got the lxml library these lines: from lxml import htmltree = html.fromstring() me write this line: htmlfile = open("My Calc Assignments full.html", "r") me more general information about lxml me better instructions on how to install/use pip ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download

To fulfill the demand for quickly locating and searching documents.

It is intelligent file search solution for home and business.

Literature Lottery

Related searches