{"id":23085,"date":"2022-01-05T14:25:41","date_gmt":"2022-01-05T14:25:41","guid":{"rendered":"https:\/\/assignmenttutors.net\/blog\/computegrade-in-python-computer-science-homework-help\/"},"modified":"2022-01-05T14:25:41","modified_gmt":"2022-01-05T14:25:41","slug":"computegrade-in-python-computer-science-homework-help","status":"publish","type":"post","link":"https:\/\/assignmenttutors.net\/blog\/computegrade-in-python-computer-science-homework-help\/","title":{"rendered":"Computegrade in python | Computer Science homework help"},"content":{"rendered":"<div>\n<p><span>Rewrite the grade program from the previous chapter using a function called computegrade that takes a score as its parameter and returns a grade as a string.<\/span><\/p>\n<table border=\"1\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"64\">\n<p><span>Score<\/span><\/p>\n<\/td>\n<td valign=\"top\" width=\"64\">\n<p><span>Grade<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"64\">\n<p><span>&gt; 0.9<\/span><\/p>\n<\/td>\n<td valign=\"top\" width=\"64\">\n<p><span>A<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"64\">\n<p><span>&gt; 0.8<\/span><\/p>\n<\/td>\n<td valign=\"top\" width=\"64\">\n<p><span>B<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"64\">\n<p><span>&gt; 0.7<\/span><\/p>\n<\/td>\n<td valign=\"top\" width=\"64\">\n<p><span>C<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"64\">\n<p><span>&gt; 0.6<\/span><\/p>\n<\/td>\n<td valign=\"top\" width=\"64\">\n<p><span>D<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"64\">\n<p><span>&lt;= 0.6<\/span><\/p>\n<\/td>\n<td valign=\"top\" width=\"64\">\n<p><span>F<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span>\u00a0<\/span><\/p>\n<p><span><span>HINT<\/span><\/span><span>:<\/span><\/p>\n<p><span><span>1.<span>\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span><span>Write a custom function with the definition <span>def computegrade(&lt;your score variable&gt;): <\/span><\/span><\/p>\n<p><span><span>2.<span>\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span><span>The function should compute the grade using the score variable based on the table above. You can use if-elif statements to accomplish this<\/span><\/p>\n<p><span><span>3.<span>\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span><span>Ensure your function has a \u201creturn\u201d statement to return the computed grade back to the calling program <\/span><\/p>\n<p><span><span>4.<span>\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span><span>Once the function is defined, proceed to writing the part of the program that takes in user input for score.<\/span><\/p>\n<p><span><span>5.<span>\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span><span>Validate that the score is numeric within a try-except block. <\/span><\/p>\n<p><span><span>6.<span>\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span><span>Invoke the above-defined computegrade function with the user-supplied score. Ensure you capture the return value within your program into a variable placeholder, or else use the print statement to print the return value directly<\/span><\/p>\n<p><span><span>7.<span>\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span><span>Be sure to comment your program adequately!<\/span><\/p>\n<p><span><span>8.<span>\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span><span>Remember your Python code will be graded according to our class Rubric.<\/span><\/p>\n<p><span><span>9.<span>\u00a0\u00a0\u00a0\u00a0 <\/span><\/span><\/span><span>Submit your Python code file.<span>\u00a0 <\/span>Name it \u201cXXXX-score-function.py\u201d where XXXX is your name.<span>\u00a0 <\/span><\/span><\/p>\n<p><span><span>10.<span>\u00a0 <\/span><\/span><\/span><span>Submit also a Word document showing screen shots of the various testing conditions.<span>\u00a0 <\/span>Good programmers test all cases, so you should make sure you show tests for each possible grade level (A through F) plus error messages.<\/span><\/p>\n<p><span>\u00a0<\/span><\/p>\n<p><span>here is the code I did. run it, it works.<\/span><\/p>\n<p><span>just need to reflect the computegrade and make that work too<\/span><\/p>\n<p><span>\u00a0<\/span><\/p>\n<p># Given a given a numerical grade between 0.0 and 1.0<\/p>\n<p>#This program converts the numerical score in letter grade.<\/p>\n<p>\u00a0<\/p>\n<p>#Prompt user for score between 0.0 and 1.0<\/p>\n<p>prompt1 = &#8220;Please enter a score between 0.0 and 1.0: &#8220;<\/p>\n<p>\u00a0<\/p>\n<p>#convert input to float, because the input statement accepts user input as a string by default<\/p>\n<p>#Wrap within a try-except code block to exit gracefully as the conversion will fall if the user supplied a non-numeric input!<\/p>\n<p>try:<\/p>\n<p>\u00a0 score = input (prompt1)<\/p>\n<p>\u00a0 score = float(score)<\/p>\n<p>\u00a0<\/p>\n<p>#Print the result<\/p>\n<p>\u00a0 if score &lt;=1.0:<\/p>\n<p>\u00a0 \u00a0if 0.9 &lt;= score &lt;= 1.0:<\/p>\n<p>\u00a0 \u00a0 \u00a0 print(&#8220;Your grade is an A&#8221;)<\/p>\n<p>\u00a0 \u00a0elif score &gt;= 0.8:<\/p>\n<p>\u00a0 \u00a0 \u00a0 print(&#8220;Your grade is a B&#8221;)<\/p>\n<p>\u00a0 \u00a0elif score &gt;= 0.7:<\/p>\n<p>\u00a0 \u00a0 \u00a0 print(&#8220;Your grade is a C&#8221;)<\/p>\n<p>\u00a0 \u00a0elif score &gt;= 0.6:<\/p>\n<p>\u00a0 \u00a0 \u00a0 print(&#8220;Your grade is a D&#8221;)<\/p>\n<p>\u00a0 \u00a0elif score &lt; \u00a00.6:<\/p>\n<p>\u00a0 \u00a0 \u00a0 print(&#8220;Your grade is an F&#8221;)<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0 else: \u00a0\u00a0<\/p>\n<p>\u00a0 \u00a0print (&#8220;Error, score cannot be greater than 1.0&#8221;)<\/p>\n<p>except:<\/p>\n<p>\u00a0 \u00a0print (&#8220;Error, please enter a number&#8221;)<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>#End of Script<\/p>\n<p>\u00a0<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Rewrite the grade program from the previous chapter using a function called computegrade that takes a score as its parameter and returns a grade as a string. Score Grade &gt; 0.9 A &gt; 0.8 B &gt; 0.7 C &gt; 0.6 D &lt;= 0.6 F \u00a0 HINT: 1.\u00a0\u00a0\u00a0\u00a0 Write a custom function with the definition def [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-23085","post","type-post","status-publish","format-standard","hentry","category-education"],"_links":{"self":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/23085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/comments?post=23085"}],"version-history":[{"count":0,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/23085\/revisions"}],"wp:attachment":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/media?parent=23085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/categories?post=23085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/tags?post=23085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}