# So I am trying to learn Python

#### Wendy

Joined Mar 24, 2008
23,140
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

#### Tesla23

Joined May 10, 2009
524
Try:
Code:
w=float(input('width?'))
I think that 'input' returns a string.

#### Wendy

Joined Mar 24, 2008
23,140
OK, thanks, will do.

#### dl324

Joined Mar 30, 2015
15,511

I thought about learning Python. That was before I decided I could get by with Perl, shell scripting, and C.

#### Wendy

Joined Mar 24, 2008
23,140
Didn't work not sure why.

#### Attachments

• 17.3 KB Views: 9

#### Wendy

Joined Mar 24, 2008
23,140
Tried something else that did not work.

#### Attachments

• 24.8 KB Views: 4

#### Wendy

Joined Mar 24, 2008
23,140
And again:

#### Attachments

• 53.1 KB Views: 9

#### michael8

Joined Jan 11, 2015
336
Sin60 and sin60 are two different names -- watch the upper lowercase...

#### MrSalts

Joined Apr 2, 2020
2,767
Change line 7 to...
print(r)

#### Wendy

Joined Mar 24, 2008
23,140
Thanks that did it.

#### Attachments

• 20.3 KB Views: 7

#### 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.

#### Wendy

Joined Mar 24, 2008
23,140
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

• 8.5 KB Views: 4
• 132 bytes Views: 4

#### Wendy

Joined Mar 24, 2008
23,140
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
The weird part is I wrote the code using notepad then changed the ext to .PY after saving it. Clunky but I am learning.
It is much easier to use a Python IDE - like IDLE

it is much, much easier to learn with w3schools.com (or similar). It hasPython simulator built into the site.
https://www.w3schools.com/python/default.asp

#### 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.

#### Wendy

Joined Mar 24, 2008
23,140

#### WBahn

Joined Mar 31, 2012
28,192
Another Python IDE that is intended for learners is Thonny.

#### MrSalts

Joined Apr 2, 2020
2,767
Another Python IDE that is intended for learners is Thonny.
That's the new default on raspberry pi

#### bidrohini

Joined Jul 29, 2022
142
Try this way:
Code:
sin60=0.866025
print('Width?')
w= int(input())
a = w / 2
b = a / sin60
c = b / 2
r = ( b / 2 ) + c
print(r)

#### WBahn

Joined Mar 31, 2012
28,192
Try this way:
Code:
sin60=0.866025
print('Width?')
w= int(input())
a = w / 2
b = a / sin60
c = b / 2
r = ( b / 2 ) + c
print(r)
Why should the width of a nut be required to be an integer?