So I am trying to learn Python

Thread Starter

Wendy

Joined Mar 24, 2008
23,415
The nut is never an integer so I can't use integers. Thanks for the help guys I will be back with other questions.
 

MrSalts

Joined Apr 2, 2020
2,767
The nut is never an integer so I can't use integers. Thanks for the help guys I will be back with other questions.

Never? More like, "not typically".
If "Good enough is the enemy of the best", I assume you wanted the most accurate answer.
3AF21980-E180-4C95-A49D-890FC130A96E.jpeg
 

strantor

Joined Oct 3, 2010
6,782
Thonny and Idle IDEs are both frustratingly basic IMO. Good choices for RPi, hence why my last distro had both installed already.

PyCharm is 1000% better. It's way bigger and demands more resources but it's worth it. Community edition is free, and fully featured as far as I know. I've never encountered a feature that I needed but was only included in professional.
 

Thread Starter

Wendy

Joined Mar 24, 2008
23,415
When doing a 3D print you need to know the radius of the Polygon. This program (in theory) calculates that radius. I will need to go over the math again in the diagram because I do think I got something wrong. I know what the answer is empirically and the calculated value is nowhere close to that.
 

WBahn

Joined Mar 31, 2012
29,978
When doing a 3D print you need to know the radius of the Polygon. This program (in theory) calculates that radius. I will need to go over the math again in the diagram because I do think I got something wrong. I know what the answer is empirically and the calculated value is nowhere close to that.
Look at the diagram. That formula does NOT yield the radius, but the diameter.

If you want the radius, divide that result by two.

Or just simply the formula first to get

radius = width / (2*sin(60°))
radius = 1.1547*width
 

Thread Starter

Wendy

Joined Mar 24, 2008
23,415
I knew that, but it still doesn't work either way. The answer should be approximately 0.118 radius as done on a 3D printer.
 

WBahn

Joined Mar 31, 2012
29,978
I knew that, but it still doesn't work either way. The answer should be approximately 0.118 radius as done on a 3D printer.
The answer to what? You aren't giving us enough information to know what the answer should or shouldn't be.

What is the width (i.e., flat-to-flat distance) of the nut you are trying to find the radius (i.e. distance from centerline to point of the hex body) of?

Don't just give a number, a number is not a distance. Be sure to include the units.
 

Thread Starter

Wendy

Joined Mar 24, 2008
23,415
Nuts, inches. I plan on starting another thread in the science and technology forum about this problem.
 
Last edited:

ApacheKid

Joined Jan 12, 2015
1,533
The weird part is I wrote the code using notepad then changed the ext to .PY after saving it. Clunky but I am learning. Hey, it was my first real program in Python. Now on to loops.
Hi,

I want to recommend you consider using Visual Studio Code (as opposed to Visual Studio) for your editing needs. VS Code (as it's also known) is a superb code editor, there are a huge number of extensions you can install for all kinds of language, using that with a suitable Python extension could be very helpful, syntax coloring and all sorts.
 

MrSalts

Joined Apr 2, 2020
2,767
I'll stick with stock Python (if there is such a thing) for the moment.
I think there is a misunderstanding of what an IDE or code editor is vs what a Python interpreter does. Python 3.12 is Python 3.12 no matter if you are wrong it in notepad and running from the console (dos window/CMD window) or clicking run from the IDE tool bar.
 

strantor

Joined Oct 3, 2010
6,782
I think there is a misunderstanding of what an IDE or code editor is vs what a Python interpreter does. Python 3.12 is Python 3.12 no matter if you are wrong it in notepad and running from the console (dos window/CMD window) or clicking run from the IDE tool bar.
Yes and using a full-featured IDE like PyCharm will greatly help with the beginner's mistakes (as opposed to notepad). Stuff like "sin60" vs "Sin60" would have been autocorrected.
 

Thread Starter

Wendy

Joined Mar 24, 2008
23,415
What I was doing until I found idle in the Python folder what is writing it using notepad then changing the extension to .py, kludgy but it worked.
 

WBahn

Joined Mar 31, 2012
29,978
What I was doing until I found idle in the Python folder what is writing it using notepad then changing the extension to .py, kludgy but it worked.
Writing it in a text editor, like Notepad (you might want to look into Notepad++) is fine. You give up some of the features that a Python-aware IDE offers, such as syntax highlighting, context-sensitive help, code completion, etc. But there's nothing intrinsically wrong with that approach. You also don't have to use a .txt extension and then change it later to .py. When you save it, just explicitly add the extension you want. If you choose to keep going this way, you can also associate the .py extension with Notepad (or whatever editor you end up using).

Others have suggested more feature-rich IDEs like PyCharm or VSC. These have a lot of advantages, but they also have a learning curve associated with them and sometimes they are frustrating to get started for a newbie because you have to learn how to do simple things in that IDE, which is not always obvious. The learning curve isn't huge, but it is there. If you are going to be writing Python code on a somewhat regular basis, getting through the curve is almost certainly worth it. But if you are going to go a few months between writing code, you might want to stick to a simpler IDE because you might end up having to relearn how to do the simple things in the fuller IDE every time you sit down to write a program.

If you use an IDE that has automatic code completion, you may or may not like it. As a rule, I do NOT like it, as it tends to really mess up my flow of development. Some are pretty good at detecting when you are going ahead and typing what it just added, but others are pretty bad about it and so you end up with two of somethings that you then have to go back and delete. Fortunately, most (if not all) of the IDEs that offer code-completion have a way to turn it off, so don't let it dissuade you from the IDE if you find it annoying, just figure out how to disable it.
 

Thread Starter

Wendy

Joined Mar 24, 2008
23,415
To be honest I was stuck in my house due to the ice storms, which motivated me to advance my goal on learning Python. Things are going to start getting busy again, I will pick back up when I don't have anything else going on. I also have an electronics project I am stuck on that I want to move to the front burner.
 
Top