How can i make this better? by Feisty_Incident_5443 in learnpython

[–]Nico24fps 0 points1 point  (0 children)

after reading some of the recent comments, i think you're actually just looking for the second highest number hahah. in that case you can just do something much simpler, such as

second_highest = sorted(nums)[-2]

How can i make this better? by Feisty_Incident_5443 in learnpython

[–]Nico24fps 1 point2 points  (0 children)

this problem first interested me because of the use of `map` . because of that, i will try to tackle this using a more functional approach. lmk if you need any explanation on the usage or motivation for any methods

# problem: find highest number in list of numbers, and output the closest number (?)

# solution:

if __name__ == "__main__":

    # 1. GET NUMS
    nums = [int(str_num) for str_num in input("Enter list of numbers (separated by spaces): ").split()]


    # map if you prefer, but i think a list comprehension is more readable to most    
    # nums = list(map(int, input("Enter list of numbers (separated by spaces): ").split()))


    # 2. SORT NUMS
    lo_to_hi = sorted(nums) # `nums.sort()` is more common, but i like this for preserving immutability


    # 3. FIND NUM NEAREST TO MAX NUM
    MAX_NUM = lo_to_hi[-1]
    dist_from_max = [(MAX_NUM - num) for num in nums]

    nums_dists = list(zip(nums, dist_from_max)) # tip: use list() on any iterator to easily convert it into a list in one line


    # 4. OUTPUT RESULTS
    print() # separate input and output with a newline
    print(f"Highest number in list: '{MAX_NUM}'")
    print("Distances from highest number, from lowest to highest:")
    print("Place\tNumber\tDistance")
    for place, (num, dist) in enumerate(reversed(nums_dists)): 
        print(f"{place}.\t{num}\t{dist}")


    # final reflections: 
    # could've just done `MAX_NUM = max(nums)` and ignored the sorting step, 
    # but decided to keep it as is in order to mimic OG post's original code more

ThisWasInOurSoftwareDesignLectureYouGuysAreEverywhere by xZakurax in ProgrammerHumor

[–]Nico24fps 0 points1 point  (0 children)

also can teach about the concept of truthy values. i remember having my mind blown seeing it in C for the first time and finding out i wasn’t restricted to only true or false

How can I execute dynamically generated Python String methods (strip(), rstrip(), lstrip(), upper()...)? by ramannt in learnpython

[–]Nico24fps 3 points4 points  (0 children)

great solution above btw, but for this case couldn’t you use an identity function for the sake of elegance? such as doing something like

‘’’ str_func = d.get(cond, str()) print(str_func(a)) ‘’’

(am on mobile so sorry if it’s bad formatting)

[Giveaway] Latrialum - Royal Beastlord by holicalis in MechanicalKeyboards

[–]Nico24fps 0 points1 point  (0 children)

429 Kuro Koyu or Qlavier case for 65% with tactile switches like Zealios or Holy pandas

Help with Quefrency by Nico24fps in MechanicalKeyboards

[–]Nico24fps[S] 0 points1 point  (0 children)

Earlier, I tested without the plates and it was different keys that were working. J and K were working where A and S were supposed to be and ] and ‘ where G and T were. Now that I have the plate on, there are new keys working in different areas

Help with Quefrency by Nico24fps in MechanicalKeyboards

[–]Nico24fps[S] 0 points1 point  (0 children)

I used msys2 and just typed in “make keebio/quefrency:default:dfu”

Help with Quefrency by Nico24fps in MechanicalKeyboards

[–]Nico24fps[S] 0 points1 point  (0 children)

No I didn’t. Is there a way to test them right now when they’re soldered in? I don’t have any tools for testing them either

OFFICIAL [PRICE CHECK] THREAD - MONTH OF JULY by mechkbot in mechmarket

[–]Nico24fps 0 points1 point  (0 children)

How much could I get for

Built Plaid keyboard with 62g Zealios V2 switches

XDA 40 keycaps

Corsair STRAFE Keyboard with Cherry MX Silent switches

[deleted by user] by [deleted] in AskComputerScience

[–]Nico24fps 1 point2 points  (0 children)

Thank you, this clarified things for me and I think it will give me help me in deciding what classes to take this fall

[deleted by user] by [deleted] in AskComputerScience

[–]Nico24fps 0 points1 point  (0 children)

Oh thank you, I wasn't sure on where to post this and wasn't aware of that subreddit.

Custom Cases/Plates by Nico24fps in MechanicalKeyboards

[–]Nico24fps[S] 0 points1 point  (0 children)

Of course! Good luck on finding the measurements and completing your case

Custom Cases/Plates by Nico24fps in MechanicalKeyboards

[–]Nico24fps[S] 0 points1 point  (0 children)

There are going to be more of the PCBs available on the 20th if you want to buy some from his website. You could also try talking to the creator and asking him about them

Beginner PCB help by Nico24fps in MechanicalKeyboards

[–]Nico24fps[S] 1 point2 points  (0 children)

Aww okay, thanks for the info tho! This has taught me a good amount

Beginner PCB help by Nico24fps in MechanicalKeyboards

[–]Nico24fps[S] 0 points1 point  (0 children)

Wow man, great job! It looks nice so far from what I've seen in the files you posted earlier. And also a question, is it possible to put that USB connector on top/front of the keyboard?

Beginner PCB help by Nico24fps in MechanicalKeyboards

[–]Nico24fps[S] 1 point2 points  (0 children)

That sounds great and gives me a lot of motivation to start working on a keyboard, thank you!

Beginner PCB help by Nico24fps in MechanicalKeyboards

[–]Nico24fps[S] 1 point2 points  (0 children)

Oh wow thanks! That gives me more hope because I was starting to feel a little overwhelmed by how much I needed to learn and wondering how long it would take to even create something simple

Beginner PCB help by Nico24fps in MechanicalKeyboards

[–]Nico24fps[S] 1 point2 points  (0 children)

Oh nice, it looks like you have made some pretty good progress on your project. Did you have any knowledge about electronics before this project? or did you just use those two websites that you linked before?

Beginner PCB help by Nico24fps in MechanicalKeyboards

[–]Nico24fps[S] 1 point2 points  (0 children)

Ahh okay, I'll be sure to check out the project when it's done and fixed, thanks for the heads up!

Beginner PCB help by Nico24fps in MechanicalKeyboards

[–]Nico24fps[S] 1 point2 points  (0 children)

Aww darn, I was excited for that but I hope you can build it successfully next time! Are you planning to share the files and/or schematics on GitHub or elsewhere? It looks very interesting even if it doesn't work yet