23
Awesome Team
Matthias
Last seen 1 month ago
Member for 1 year, 8 months, 22 days
Difficulty Normal
It's an interesting idea to use a Lightbulb class.
If you like, you could condense the code a bit. For example:
The function change_state(...) considers 3 cases:
a) change_state_time is None #happens at the 1st event only
b) state == on
c) anything else #equals
More
I wasn't able to give -3 points, because the total number has to be non-negative.
That's why I decided to give "+3", so the next visitor can fulfill your wish for sure ;-)
More
Could you please explain, _why_ you consider this solution to be "creative"? To me it looks quite straightforward.
Oh, and please forgive my nosiness, but...
Why do you check for `== 0`, instead of writing `checkio = lambda v: str(v) if v % 3 else 'Fizz'` ?
More
The first condition states "should be bigger than 6", but the code checks for "at least 6":
c1 = len(password) >= 6
That should be changed into '>6' or '>=7'.
More
it's nice to learn something new about statistics π
https://en.wikipedia.org/wiki/Mode_(statistics)
More
That's a very well documented function. The coding is straight forward π
More
Thank you for this example. Now I know more about regular expressions and how to handle them in Python.
Edit:
removed second part of my comment, because @amandel was faster ;-)
More
Thank you for this cultural reference when I expected _him_ the least. And thanks at @9Teen90Three for pointing out the context.
More
nice one-liner on base=10 π
unfortunately, meanwhile the task changed to any arbitrary base B....
More
Could you please explain why you rule out `radix == 15` and `radix == 9` ?
In my opinion 'A' to the base of 15 should give '10' and not '-1':
>>> int('A',15)
10
More
works fine :) You might replace / by //, so we don't need to convert the result using int()
centre = count // 2 if count % 2 == 0 else count // 2 + 1
More
I gave 3 points:
- one for the solution
- two for having "?!" in the subject line
Normally I strain to use the most simple solution. But here simply comparing strings alphabetically feels kinda "wrong".... π€·ββοΈ
More
such simple tasks are a good point to introduce `lambda` , because there's no other code which could bring confusion π
More
nice, straight-forward solution.
another way to handle different values of item would be "match-case", which is quite new:
https://docs.python.org/3/reference/compound_stmts.html#the-match-statement
More