So I am trying to learn Python

Thread Starter

Wendy

Joined Mar 24, 2008
23,415
And I cannot get this program to work. Any ideas?

Code:
sin60=0.866025
w=input('width?')
a = w / 2
b = a / sin60
c = b / 2
r = ( b / 2 ) + c
r
How to Calculate Hex Nut Dimensions.GIF
 

MrSalts

Joined Apr 2, 2020
2,767
Also change input line to...

print("Enter Width:")
w=float(input())

If you are using an online simulator of Python, you cannot use the input command.
 

Thread Starter

Wendy

Joined Mar 24, 2008
23,415
Actually I can and did, I also used input to freeze the display so I can view the result.
Code:
sin60 = float(0.866025)
w = float(input('width?'))
a = w / 2
b = a / sin60
c = b / 2
r = ( b / 2 ) + c
print(r/2)
z=input()
 

Attachments

Thread Starter

Wendy

Joined Mar 24, 2008
23,415
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.
 
Last edited:

MrSalts

Joined Apr 2, 2020
2,767
If you have Python installed on a windows machine, you should be able to right click on a .py script and select "edit" - the Idle IDE should open. You can also look at your start menu to see if the windows IDE popped up in there when you installed Python. Last option, type "idle" in the start search box. All (any) should work.
The IDE us very easy to use and there is an IDLE shell that opens each time you click run to test your script.
 
Top