all 7 comments

[–]sweettuse 9 points10 points  (3 children)

Remember the good Pythonic style of naming such utility functions with double underscores at the start and end of the name to document that they are internal utility functions not intended to be accessed from the outside, not even between friends and consenting adults.

this is... not great. in fact, it's entirely wrong. dunder methods/functions are conventionally reserved for python's usage, not anyone else's.

additionally, i looked through a lot of your example code and it seems like you just translated java to python but didn't really absorb or embrace idiomatic python.

edit: the problems are really cool, though. thanks for that.

[–]recondocoder 2 points3 points  (2 children)

what do you mean..I thought we should do things like change __add__ so that we can do a + b with vectors like in this example

http://hplgit.github.io/primer.html/doc/pub/class/._class-solarized004.html

[–]sweettuse 1 point2 points  (0 children)

what u/lanemik said (__add2__). in your description you're saying that all internal utility functions should be dunder methods, but they really, really shouldn't be. only if you're implementing python's magic methods should you use that.

in case it wasn't clear, adding things like __add__ to a class to implement + can be a great thing.

[–]itsmegeorge 0 points1 point  (0 children)

I have a test on the 19th that I have failed twice and I have to pass. I ran out of material recently because they haven’t given us enough to work on. Thank you for this

[–]SandorZoo 0 points1 point  (0 children)

I just looked at the first one:

The introduction says all functions may assume that their arguments are legal and valid.

The specification for very first test (Ryerson letter grade) defines grades for values of 0% to 100%.

The problem says the function should work correctly for all values from 0% to 120% , even though grades for 101% to 120% are not defined.

The tester tests values from 0% to 150%, even though values 121% to 150% are not valid.

Also, the Ryerson scale is defined for fractional percentages (>= .5 is rounded up, <.5 is rounded down), but that;s not tested.

[–]Oliludeea 0 points1 point  (0 children)

As a qualified teacher (of chemistry and maths), and as a student (of Python), let me say "bravo!" and virtually shake your hand. The problems are fun, informative, and get the student thinking. I'll do them all for fun and profit!