[Tutor] How do you save work in progress in Pyscripter ?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Tutor] How do you save work in progress in Pyscripter ?

Thomas Mujica

Please help a newbie

 

Was able to write and successfully run this but I can’t seem to be able to “save” it

 

Luckily I had saved it to Word and then I was able to copy and paste it back into PyScripter.

 

I’m using

 

Python Scripter Version 2.5.3.0 x86

 

*** Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32. ***

*** Remote Python engine  is active ***

>>> 

 

>>> from decimal import *

>>> getcontext()

Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999, capitals=1, flags=[], traps=[DivisionByZero, InvalidOperation, Overflow])

>>> getcontext().prec=3                    #change decimal precision to 3 decimal places

>>> for a in xrange(1,30): #NESTED   note no matter what the variables are the syntax is always xrange

...     for b in xrange(1,30): #LOOPS DO 29 ITERATIONS

...         c=pow(a,2)+pow(b,2)            # this is really c squared because a and b are raised to exponent 2

...         h=pow(c,.5)                           #pow is .5 so h is the square root of c …..h is the hypotenuse

...         d=round(h,2)

...         if a==1 and b==1:                 #will allow titles to be printed at beginning of print out

...             print "Side a","Side b","Hypotenuse"

...         if h==d and d==h:                #will eliminate all values of h that are not integers from printout

...             print"  ",a,"\t",b,"\t\t",h  #for alignment purpose “3 spaces “ before a then tab b, and 2tabs                       ...                                                                                                                                                        #     before h

 

 

 

Side a Side b Hypotenuse

    3      4                      5.0

    4      3                      5.0

    5      12                    13.0

    6      8                      10.0

    7      24                    25.0

    8      6                      10.0

    8      15                    17.0

    9      12                    15.0

    10    24                    26.0

    12    5                      13.0

    12    9                      15.0

    12    16                    20.0

    15    8                      17.0

    15    20                    25.0

    16    12                    20.0

    18    24                    30.0

    20    15                    25.0

    20    21                    29.0

    21    20                    29.0

    21    28                    35.0

    24    7                      25.0

    24    10                    26.0

    24    18                    30.0

    28    21                    35.0

 


_______________________________________________
Tutor maillist  -  [hidden email]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: [Tutor] How do you save work in progress in Pyscripter ?

Alan Gauld
On 06/04/12 20:11, Thomas Mujica wrote:

> *Was able to write and successfully run this but I can’t seem to be able
> to “save” it*

You have written the code at the interactive prompt which is really
intended for experimenting.

To save the code as a python script you need to create a plain text
file and save it with a .py extension (assuming you are on Windows).

You could use something as basic as Notepad to create it but most IDEs
or specialist programming editors will be more useful. I don;t know
pyscripter but usually you can use the File->New menu to create a new
blank editor window where you can type the code. You then save it with
File->Save/SaveAs as usual. How you run it varies by IDE...

Note you don't type the >>> and other stuff that the interpreter puts
out, so your code would look like:

from decimal import *

getcontext().prec=3 #change decimal precision to 3 decimal places*

for a in xrange(1,30): #NESTED note no matter what the variables
     for b in xrange(1,30): #LOOPS DO 29 ITERATIONS*
         c=pow(a,2)+pow(b,2) # this is really c squared because a and b are
         h=pow(c,.5) #pow is .5 so h is the square root of c …..h is the
         d=round(h,2)
         if a==1 and b==1: #will allow titles to be printed at beginning of
            print "Side a","Side b","Hypotenuse"
         if h==d and d==h: #will eliminate all values of h that are not
            print" ",a,"\t",b,"\t\t",h #for alignment purpose “3 spaces “


There are some odd things in that code that I could comment on, but for
now I'll ignore them and see if you can get the script running first.

HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  [hidden email]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor