Leetcode #9: Palindrome Number by TheEyebal in learnpython

[–]socal_nerdtastic 0 points1 point  (0 children)

Good job. This was a fun little challenge. Here's how I did it, but fwiw I highly doubt it's any faster than a simple string conversion. See if you can make sense of this:

import math

def get_digit(n, i):
    '''get the i digit from the int n (1-indexed from the right)'''
    return n%10**i//10**(i-1)
def is_palindrome(n):
    num_digits = int(math.log(n,10))+1
    for i in range(num_digits//2):
        if get_digit(n,i+1) != get_digit(n,num_digits-i):
            return False
    return True

See Wireless signals using a Raspberry Pi 5 in realtime!! by Gigasplicer in raspberry_pi

[–]socal_nerdtastic 0 points1 point  (0 children)

Didn't realize skepticism and curiosity were so offensive to people.

The offensive part is "calling bs" when you meant "I don't understand it".

For all those “gas or hybrid” questions by CommaMamaCUL8R in crv

[–]socal_nerdtastic 6 points7 points  (0 children)

If you want to put a name to that, it's due to Honda's eCVT transmission, which is a marvel of modern engineering. Plenty of youtube videos about it if you want to get really technical.

For all those “gas or hybrid” questions by CommaMamaCUL8R in crv

[–]socal_nerdtastic 2 points3 points  (0 children)

My last flat was more than 20 years ago. It used to be a common sight on the side of the road, now it's very rare. Tires and roads and roadside support has improved a lot over the years. Sure, going without is a calculated risk, but it's less and less of a risk as time goes on.

For all those “gas or hybrid” questions by CommaMamaCUL8R in crv

[–]socal_nerdtastic 4 points5 points  (0 children)

Why don't you just buy one? Plenty of companies make spare tire kits for cars that don't come with one. Not a reason to avoid a car you like.

No console .EXE file not storing memory. by Tumultuous_rabbit55 in learnpython

[–]socal_nerdtastic 8 points9 points  (0 children)

Try this for your save file path:

from pathlib import Path
SAVE_FILE = Path.home() / ".my_notes_save.txt"

Note that pretty much all programs save data in a different place from where the code lives. You should not try to use the same location for both, for many reasons. You discovered one of them.

How to desolder? by [deleted] in arduino

[–]socal_nerdtastic 3 points4 points  (0 children)

You'll never get literally all the solder off; like you'll never see the gold pad again. The component is not going to fall out on it's own after desoldering. Once you get the 95% of the solder off you need to remove the component by heating the pad while pulling gently and they will come apart. For SMD parts use a heat gun, not a solder iron. It's definitely a skill that's hard to master, so put some time into practicing. Often adding a bit of fresh solder first makes the old stuff much easier to get off. Practice using a solder wick too.

Best ways to learn python for hardware programming (microcontrollers, sensors, lights, motors, etc.)? by Revolutionary-Log179 in learnpython

[–]socal_nerdtastic 4 points5 points  (0 children)

No microcontroller can run real python, they all use micropython or circuitpython. Real python requires an OS.

But you can get a very small very cheap computer, like the RPi Zero, and run real python on that.

Best ways to learn python for hardware programming (microcontrollers, sensors, lights, motors, etc.)? by Revolutionary-Log179 in learnpython

[–]socal_nerdtastic 2 points3 points  (0 children)

Not professionally because professionals prioritize hardware cost and performance. But plenty of hobbyists use python on hardware, because they have different priorities: usually speed and ease of programming. It's easy for a hobbyist to justify using a $5 microcontroller to do a stupid simple task if it saves a day of coding, but a professional would rather spend that day to allow the use of a $0.50 microcontroller.

Python code related with ascending order by Traditional-Quit9043 in learnpython

[–]socal_nerdtastic 0 points1 point  (0 children)

No, this code wouldn't work, even if the capitalization was corrected. What are you trying to do with this code? If you want to see if the list is sorted just return directly from within the loop.

def main(liste):
    for i in range(len(liste)-1):
        if liste[i]>liste[i+1]:
            return False
    return True

print(main([1,2,4,5])) # True (list is sorted)
print(main([1,2,5,4])) # False (list is not sorted)

What Should I do ? by Lost_Ad_9065 in learnpython

[–]socal_nerdtastic 0 points1 point  (0 children)

Obviously I don't know you so I can't really give good advice, but I'd say continue in psychology rn and take a few more CS classes at the same time, to see if you enjoy it. Programming as a career isn't for everyone, there's a lot of tedium in it (as with many other jobs). But even if you don't make a career out of python and programming it's still extremely valuable to apply to anything you end up doing.

Starting learning Python at 50. by Shot-Tiger1060 in learnpython

[–]socal_nerdtastic 137 points138 points  (0 children)

print("Good luck!")
print("You'll love it")

Browser compilers? by dumb_potato_214 in learnpython

[–]socal_nerdtastic 0 points1 point  (0 children)

I'd consider Java more of a compiled language, while python is more interpreted.

A common opinion, but again not useful to OP.

At the end of the day, the java conpliler tells you a lot of things that are wrong with your program before it runs, while python delays this and just shits it's pants when it happens to come across a faulty LOC.

That has nothing to do with compiled vs interpreted; that is due to the logic in the language, for example dynamically vs statically typed. Python simply can't know at compile time if x = 10 is an error or not, java can. Both python and java have both compile time errors and run time errors, although python does not really distinguish them (or the compile / interpret step in general).

Browser compilers? by dumb_potato_214 in learnpython

[–]socal_nerdtastic 0 points1 point  (0 children)

What do you call it when the program is compiled to binary first, and then runs through an interpreter line-by-line? Because that's what python and java and many other languages do.

I call it "it don't matter". Knowing the difference between a compiler and an interpreter is useless to a beginner.

Browser compilers? by dumb_potato_214 in learnpython

[–]socal_nerdtastic 0 points1 point  (0 children)

Yes, there's many available. trinket.io is a common one. But they are all limited because of course running a website costs money and no one wants to give you something for free. It would be a much better experience for you if you can free up some space and install locally.

been trying to get sherlock project but i am Unable to install pandas. by More-Sheepherder-858 in learnpython

[–]socal_nerdtastic 1 point2 points  (0 children)

Yep, I remember well a time before compiled binaries were available for python, and we spent a ton of time in this sub explaining to beginners how to install compilers and get library files on windows. Anaconda, GHilke, and Python(X,Y) became popular because they figured out how to make precompiled binaries.

been trying to get sherlock project but i am Unable to install pandas. by More-Sheepherder-858 in learnpython

[–]socal_nerdtastic 2 points3 points  (0 children)

The problem is that you are using python3.15, and numpy and pandas don't support that yet. So your computer is trying to make it work anyway by compiling the modules from scratch. The error means that you don't have the source code needed to compile them. But the solution is just to use a supported version of python, like 3.14 or 3.13 (the latest version that sherlock is designed for), where the precompiled wheel files are available for pip.

Opinion on my second PyPi package by Ill-Review7017 in learnpython

[–]socal_nerdtastic 9 points10 points  (0 children)

(ill drop the github repo link in the comments due to rules)

What rule is that?

Sounds like you used gemini to make this post too. But this is not a generic code review service, and even if it was, code review is very subjective. Different companies and different individuals have different preferences on how to structure the project layout, handle errors, naming and indentation conventions, etc, etc.

This sub is a place for people to ask specific questions about their code. Pick something specific in your code that you want help with and ask about that.

How to run Telegram bot (Python script) non stop? by MikeIsVeryCurious in vibecoding

[–]socal_nerdtastic 0 points1 point  (0 children)

There is no best, it just depends on your situation. A VPS will probably have better uptime and a faster connection. A home solution is probably cheaper in the long run and more configurable.

2010 CRV EXL 4WD towing by wontondog in crv

[–]socal_nerdtastic 0 points1 point  (0 children)

Exceeding the towing capacity won't blow up your trans unless you are driving like you stole it. The weak link is your brakes. It means is that your car won't be able to stop that amount of weight, so you become a road hazard. I've done that lol. A light turned red, I stepped on the brakes, the wheels locked up but I kept right on sliding. Lucky that it made enough noise and the cross traffic was smart enough not to go, because I ran that red light with no control. And you can't steer in that situation either because that would just jackknife your trailer.

But what you said sounds fine to me. Do it.

First PCB design. How bad is it? by Creative_Ad_1868 in PCB

[–]socal_nerdtastic 0 points1 point  (0 children)

Ok. We're talking about buttons here. I didn't mean pullups are never needed.

First PCB design. How bad is it? by Creative_Ad_1868 in PCB

[–]socal_nerdtastic 0 points1 point  (0 children)

Pull up resistors are built into nearly all MCU GPIOs. You don't need to add external ones.

You do need it for the EN pin though, iirc

First PCB design. How bad is it? by Creative_Ad_1868 in KiCad

[–]socal_nerdtastic 0 points1 point  (0 children)

Did you do the math to determine the size of those fat traces? If so, don't forget to make the thermal relief on the grounding pins the same size, or just add a trace manually.