[web2py] Re: Getting wrong Results with my grading system
WOOOW!!! Thank you Jose i have been switching the signs, i have been using *> *as small than and *< *as greater than,i do not know when all this information got mixed up in my head but it took your words to pay close attention & realize my error. Thank you. *And honestly its not an assignment* On Sunday, November 19, 2017 at 12:09:49 PM UTC+2, Jose C wrote: > > This is starting to look like a homework assignment. You do not seem to > understand what the >= (greater than or equal to) means. > > The python statement: > if perc >=100: > grade='A' > elif perc >= 79: > grade='B' > ... > > means or reads as (in English): > if the value in 'perc' is greater than or equal to 100, then set the value > of 'grade' to 'A'. > Else if the value in perc is greater than or equal to 79 , then set the > value of grade to 'B'. > Else if the value in perc is greater than or equal to 69, then set the > value of grade to 'C' > and so on > > The above statements stop being evaluated after the first condition that > is true. > > Now can you see the error in the logic? If not, I would suggest you run > through some sample values for perc using the above statements and see if > that helps. > > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Getting wrong Results with my grading system
This is starting to look like a homework assignment. You do not seem to understand what the >= (greater than or equal to) means. The python statement: if perc >=100: grade='A' elif perc >= 79: grade='B' ... means or reads as (in English): if the value in 'perc' is greater than or equal to 100, then set the value of 'grade' to 'A'. Else if the value in perc is greater than or equal to 79 , then set the value of grade to 'B'. Else if the value in perc is greater than or equal to 69, then set the value of grade to 'C' and so on Now can you see the error in the logic? If not, I would suggest you run through some sample values for perc using the above statements and see if that helps. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Getting wrong Results with my grading system
think the answer is right in front of you (just a matter of conditional logic): What i want is to reflect an a 'A' if a student gets anything between 100% and 80%, hence the line if perc>=100: grade='A' *pls try (not tested):* if perc>=80 and perc<=100: grade='A' and get grade 'B' if a student gets anything between79% and 70% hence the line elif perc>=79: grade='B' *pls try (not tested):* elif perc>=70 perc<=79: grade='B' best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Getting wrong Results with my grading system
What i want is to reflect an a 'A' if a student gets anything between 100% and 80%, hence the line if perc>=100: grade='A' and get grade 'B' if a student gets anything between79% and 70% hence the line elif perc>=79: grade='B' elif perc>=69: grade='C' When i coded it i thought it's straight forward it'd reflect correctly but instead 70% gives me 'C' and 80% to 90% give me a 'B' I Cant figure out what I'm doing wrong where! On Sunday, November 19, 2017 at 1:06:20 AM UTC+2, Anthony wrote: > > > > On Saturday, November 18, 2017 at 9:15:36 AM UTC-5, mostwanted wrote: >> >> I want grade 'A' to fall within a range of percentages, 'A' ranges from >> 80%(being the lowest) to 100%(being the highest), how do i reflect that >> here to get the system to grade properly?? >> > > if perc >= 80: > > The upper range doesn't matter, as presumably 100 is the maximum anyway. > > Note, though, that you have defined a B as >= 79. That means that you get > a B only if your percentage is between 79 and 80 -- once you hit 80, it's > an A. Is that really what you want? > > Anthony > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Getting wrong Results with my grading system
On Saturday, November 18, 2017 at 9:15:36 AM UTC-5, mostwanted wrote: > > I want grade 'A' to fall within a range of percentages, 'A' ranges from > 80%(being the lowest) to 100%(being the highest), how do i reflect that > here to get the system to grade properly?? > if perc >= 80: The upper range doesn't matter, as presumably 100 is the maximum anyway. Note, though, that you have defined a B as >= 79. That means that you get a B only if your percentage is between 79 and 80 -- once you hit 80, it's an A. Is that really what you want? Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Getting wrong Results with my grading system
Thanks for the {{pass}} clarification, its clear now On Saturday, November 18, 2017 at 2:38:28 PM UTC+2, Anthony wrote: > > > And I'd also be grateful if someone just simple explained what {{pass}} >> does in web2py and where do we place it because i find myself placing it in >> wrong places and at times it just disrupts the balance of the entire code >> if i don't place it correctly, that'd mean a lot, thanks. >> > > The use of {{pass}} is explained here: > http://web2py.com/books/default/chapter/29/05/the-views#The-views. Python > usually defines code blocks based on indentation, but since the views do > not require proper Python indentation, we need an alternate way to define > code blocks when the boundaries are not otherwise obvious -- so you use > {{pass}} to indicate the end of a code block. For example: > > {{if some_condition:}} > This > {{else:}} > That > {{pass}} > Now we are outside the "else" block, so this line will always be displayed > . > > Without the {{pass}}, that last line would be part of the "else" block and > therefore only display conditionally. Note, we do not need a {{pass}} at > the end of the "if" block above, because the {{else:}} implies the end of > the "if" block. > > Typically, you would need a {{pass}} to indicate the end of an if, else, > elif, or for block in a view. > > Anthony > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Getting wrong Results with my grading system
I want grade 'A' to fall within a range of percentages, 'A' ranges from 80%(being the lowest) to 100%(being the highest), how do i reflect that here to get the system to grade properly?? On Saturday, November 18, 2017 at 11:05:02 AM UTC+2, Jose C wrote: > > Simple logic error... > > Your first if clause should most likely be: > if perc >= 90: > > in order to trap that value. > > > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Getting wrong Results with my grading system
> And I'd also be grateful if someone just simple explained what {{pass}} > does in web2py and where do we place it because i find myself placing it in > wrong places and at times it just disrupts the balance of the entire code > if i don't place it correctly, that'd mean a lot, thanks. > The use of {{pass}} is explained here: http://web2py.com/books/default/chapter/29/05/the-views#The-views. Python usually defines code blocks based on indentation, but since the views do not require proper Python indentation, we need an alternate way to define code blocks when the boundaries are not otherwise obvious -- so you use {{pass}} to indicate the end of a code block. For example: {{if some_condition:}} This {{else:}} That {{pass}} Now we are outside the "else" block, so this line will always be displayed. Without the {{pass}}, that last line would be part of the "else" block and therefore only display conditionally. Typically, you would need a {{pass}} to indicate the end of an if, else, elif, or for block in a view. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Getting wrong Results with my grading system
Simple logic error... Your first if clause should most likely be: if perc >= 90: in order to trap that value. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.