Note that there are some explanatory texts on larger screens.

plurals
  1. POSeparate functions in python?
    primarykey
    data
    text
    <p>I'm not sure if function is the word I am looking for. In fact I don't really know what I'm saying but I have some code and it's not quite doing it what I want to. Basically I want to copy and paste this code I've got and email it to someone. I want them to be able to simply copy and paste it into their Terminal and perform calculations.:</p> <pre><code>## SCSAC.py def round(x, base=5): return int(base * round(float(x)/base)) option = 'yes' while (option == 'yes'): x=float(raw_input('How many accumulated orders do you have from retailers: ')); y=float(raw_input('How many units are in the inventory: ')); z=float(raw_input('How many accumulated orders have you placed: ')); print 'Place an order of %s units' % round(((x / 25 + y / 10 + z / 25) + 115)); print ; option=raw_input("Do you wish to calculate another order? (Enter 'yes' to continue or any other key to quit):: "); print </code></pre> <p>Whenever I type this code in line for line, it works perfectly. That's because there are basically 3 seperate things happening here. </p> <ol> <li><p>I define "round" which rounds a value to the nearest 5.</p></li> <li><p>I define an option to loop the program upon completion</p></li> <li><p>I define the actual program, and in that I round the answer and conclude with the option to loop. You may notice 2 <code>print</code>'s that don't print anything, but they are only there to have blank lines. </p></li> </ol> <p>When I copy and paste it, I get a syntax error. I am not a programmer and I have just been playing with this all day. I just want to know how I can edit this code so it is copy/paste-able and will run the way it is supposed to. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload