Re: [Tutor] Urgent Help Required

2012-02-04 Thread Dave Angel

On 02/04/2012 08:17 AM, Zafrullah Syed wrote:

Hi,

I need urgent help:

I am unable to commit code to svn, I am getting this warning:

*svn: Commit failed (details follow):*
*svn: Commit blocked by pre-commit hook (exit code 1) with output:*
*string:17: Warning: 'with' will become a reserved keyword in Python 2.6*
*writeConf.py:17: invalid syntax*
*Commited Python-Files refused, please check and retry...*

How do i surpass this and commit my code??

Lousy choice of subject.  Please make your subject reflect what your 
problem is, not how important it may or may not be to you.


You're not just running svn.  If you were, you'd not get some python 
error or warning.  So you're running a more complex environment, perhaps 
svn integrated inside some IDE (like komodo, wingware, beans, whatever).


If so, post a question on the forum that supports that particular IDE.  
Or if you must post here, at least give us a clue what environment 
you're using.  For example, i can infer that you're running Python 2.5 
or older.  But it'd be much better to explicitly say what python 
version, which operating system (and version), and what IDE (and 
version), and what svn (get the pattern?).


The svn command to submit changes to a file outside of the ide is  svn 
commit filename.  If the file is new, I believe you have to do an svn add.




--

DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] urgent help!!!!!!!!!!!

2011-11-18 Thread Emile van Sebille

On 11/17/2011 3:26 PM ADRIAN KELLY said...

i know i'm stupid but i have tried everything to get one line of text
working, i have written out pseudo and read every website.
now i am getting this error

Traceback (most recent call last):
File F:\VTOS ATHLONE\PYTHON_VTOS\foreign exchange\f_ex4 - Copy.py,
line 24, in module
main()
File F:\VTOS ATHLONE\PYTHON_VTOS\foreign exchange\f_ex4 - Copy.py,
line 14, in main
while amount50:
UnboundLocalError: local variable 'amount' referenced before assignment




You've seen the fixes, but perhaps more explanation helps too.

Python organizes variables into namespaces.  The normal namespace 
resolution sequence is local, global, builtin.  Assigning to a name 
within a function creates a local variable, otherwise accessing a name 
in a function will use the global or builtin namespaces.  Python decides 
these issues in part during initial loading of the module where it sees 
that you assign to the variable amount within the function, thus 
creating a local variable.  Later, during execution, you first test the 
value of amount (in the while statement), but amount isn't assigned to 
until after the test, ergo, UnboundLocalError.


HTH,

Emile



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] urgent help!!!!!!!!!!!

2011-11-17 Thread Alex Hall
My mail client stripped new lines, at least on this machine, so I will
just top-post this. Sorry!
Your problem is that you say:
amount=0
def main()...
You then try to use amount in main, but main has no amount in it.
Either move amount=0 inside main, or put a global reference:
amount=0
def main():
global amount
...

On 11/17/11, ADRIAN KELLY kellyadr...@hotmail.com wrote:

 i know i'm stupid but i have tried everything to get one line of text
 working, i have written out pseudo and read every website.now i am
 getting this error
 Traceback (most recent call last):  File F:\VTOS
 ATHLONE\PYTHON_VTOS\foreign exchange\f_ex4 - Copy.py, line 24, in module
   main()  File F:\VTOS ATHLONE\PYTHON_VTOS\foreign exchange\f_ex4 -
 Copy.py, line 14, in mainwhile amount50:UnboundLocalError: local
 variable 'amount' referenced before assignment


 def exchange(cash_in):euro=1dollar=1.35base=50if
 cash_inbase:totalreturn=cash_in*dollarelse:
 totalreturn=0return totalreturn
 amount=0def main():while amount50:amount = raw_input(float('how
 much do you want to change:'))if amount50:total=0print
 'enter an amount over 50: 'else:total=exchange(amount)
 print 'Your exchange comes to: ',total




 Adrian Kelly
 1 Bramble Close

 Baylough

 Athlone

 County Westmeath

 0879495663


 From: waynejwer...@gmail.com
 Date: Thu, 17 Nov 2011 16:53:59 -0600
 Subject: Re: [Tutor] please help - stuck for hours
 To: kellyadr...@hotmail.com
 CC: tutor@python.org

 On Thu, Nov 17, 2011 at 4:32 PM, ADRIAN KELLY kellyadr...@hotmail.com
 wrote:








 thanks very much, great response really really appreciated it and now i
 understand. i hate to ask again but can you see why it won't print the
 'enter and amount over 50' in the right place??


 Computers are unfailingly stupid machines. They will do whatever wrong thing
 you tell them to do every single time.

  snipdef main():amount=0while amount50:amount =
 input('how much do you want to change:')

 print 'enter an amount over €50: 'else:
 total=exchange(amount)print 'Your exchange comes to: ',total


 Sometimes it helps writing out the logic in steps before you translate it to
 code. In this case my guess is that these are the steps you want:
   1. Get a value from the user (you're still using input - stop that, it's
 dangerous! input is   only a good function in 3.x where it replaces
 raw_input)

2. If the value is less than 50, tell the user to enter an amount  50
 and repeat step 1
   3. Otherwise, exchange the amount and display that.
 Right now, these are the steps that you're doing:


   1. Get a value from the user
   2. Display the error message
   3. If the value is  50, go to 1
   4. exchange the amount


   5. display the amount.
 HTH,Wayne 


-- 
Have a great day,
Alex (msg sent from GMail website)
mehg...@gmail.com; http://www.facebook.com/mehgcap
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] urgent help!!!!!!!!!!!

2011-11-17 Thread Prasad, Ramit
def exchange(cash_in):
    euro=1
    dollar=1.35
    base=50
    if cash_inbase:
        totalreturn=cash_in*dollar
    else:
        totalreturn=0
    return totalreturn

amount=0
# this would be better placed inside the main function.
def main():
    while amount50:
        amount = raw_input(float('how much do you want to change:'))
# This should be 
# amount = float( raw_input('how much do you want to change:' ) )
    if amount50:
        total=0
        print 'enter an amount over 50: '
    else:
        total=exchange(amount)
        print 'Your exchange comes to: ',total


Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] urgent help required! invalid syntax

2011-02-18 Thread Timo
On 18-02-11 09:42, lim chee siong wrote:


 Hi,

 I was writing a module for the black-scholes pricing model in python,
 but I keep getting this error message:

 Traceback (most recent call last):
 File stdin, line 1, in module
 File C:\Python26\lib\blackscholes.py, line 25
 d2=d1-v*sqrt(t)
That's not the whole traceback, is it?


 This is the code in my blackscholes.py file:
 #Black-Scholes model

 [snip]

 def dividend(s,x,r,t,v):
 d1=(log(s/x)+((r+v**2/2)*t)/(v*sqrt(t))
 d2=d1-v*sqrt(t)

 [snip]


 What is wrong here? What do I need to change?
Check the line before the line which throws a syntax error. Have a good
look at it and you will see you are missing a character.

Cheers,
Timo

 Thanks! Quick reply will be much appreciated because the deadline is
 tomorrow!


 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] urgent help required! invalid syntax

2011-02-18 Thread Steven D'Aprano
lim chee siong wrote:
 
 
 Hi,
 I was writing a module for the black-scholes pricing model in python, but I 
 keep getting this error message: 
 Traceback (most recent call last):  File stdin, line 1, in module  File 
 C:\Python26\lib\blackscholes.py, line 25d2=d1-v*sqrt(t) 


Please COPY AND PASTE the FULL error message, including the entire
traceback. Do not re-type it, summarise it, simplify it, or change it in
any other way.

But my guess is that you're probably missing a closing bracket ) on that
line, or the one before it.



-- 
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] urgent help required! invalid syntax

2011-02-18 Thread James Reynolds
There's a few things I've noticed:

1. I would recommend using an IDE of some sort. I copy and pasted this into
eclipse, and it told me straight away that you had a parenthesis problem on
this line: d1=(log(s/x)+((r+v**2/2)*t)/(v*sqrt(t))

2. Your function dividend isn't returning a value.

3. Unless there is more to the program that you haven't shown us, all of the
math stuff that I can see, such as sqrt, pi, log, exp and possibly others
I'm not thinking of should be prefixed with math..

4. The function BS isn't returning anything.

5. Lastly, if you are a familiar with object oriented programing, the black
scholes is better suited towards OOP.

2011/2/18 lim chee siong doggy_lolli...@hotmail.com



 Hi,

 I was writing a module for the black-scholes pricing model in python, but I
 keep getting this error message:

 Traceback (most recent call last):
   File stdin, line 1, in module
   File C:\Python26\lib\blackscholes.py, line 25
 d2=d1-v*sqrt(t)


 This is the code in my blackscholes.py file:
 #Black-Scholes model

 import math
 import numpy
 import scipy

 #Cumulative normal distribution

 def CND(x):

   
 (a1,a2,a3,a4,a5)=(0.31938153,-0.356563782,1.781477937,-1.821255978,1.330274429)
   L=abs(x)
   K=1.0/(1.0+0.2316419*L)
   
 w=1.0-1.0/sqrt(2*pi)*exp(-L*L/2)*(a1*K+a2*K*K+a3*pow(K,3)+a4*pow(K,4)+a5*pow(K,
 5))
   if x0:
 w=1.0-w
   return w

 #s: price of underlying stockx:strike price
 #r: continuously compounded risk free interest rate
 #t: time in years until expiration of option
 #v: implied volatility of underlying stock

 def dividend(s,x,r,t,v):
   d1=(log(s/x)+((r+v**2/2)*t)/(v*sqrt(t))
   d2=d1-v*sqrt(t)

 def BS(s,x,r,t,v):
   c=s*CND(d1)-x*exp(-r*t)*CND(d2)
   p=x*exp(-r*t)*CND(-d2)-s*CND(-d1)
   delta=CND(d1)-1
   gamma=CND(d1)/(s*v*sqrt(t))
   vega=s*CND(d1)*sqrt(t)
   theta=-((s*CND(d1)*v)/(2*sqrt(t))+r*x*exp(-r*t)*CND(-d2)
   rho=-x*t*exp(-r*t)*CND(-d2)


 What is wrong here? What do I need to change? Thanks! Quick reply will be
 much appreciated because the deadline is tomorrow!


 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Urgent: Help

2008-01-07 Thread Alan Gauld
Shumail Siddiqui [EMAIL PROTECTED] wrote

   I have a question regarding a functions based assignment. The 
 assignment is:
  For this project, you will write two small Python programs:


OK, Since this is for homework I cannot give you the answers
but I will point out some things you shouild look at and an approach.


   Investment Thresholds

  Define a Python function threshold(dailyGains, goal) that 
 behaves as follows.

First define the function and test it using the  prompt.

  Write a small Python program that uses your threshold() 
 function
 to demonstrate that it works correctly. Your program may use a
 pre-defined list of stock gains or it may generate one randomly

Use a predefined list initially, it's easier!
Only once that works try introducing random elements.

   Word Windows

One problem at a time...

  This is what I have so far:

  import random
 dailyGains = int(random.range(6))
 goal = random.choice(range(4)

missing parenthesis, I assume a typo?

 result = []
 def threshold(dailyGains, goal):
  if goal!= result: 0
  else:
result.reverse()
result.remove()

you need to investigate the return statement in functions.

However I don;t understand how you think this will
achieve anything like what the original specification
asked for. You need to use the dailyGains list
somewhere... And why you are checking against
result I don't know.

Can you describe in English what the function should
do and how you would go about it manually using
pen and paper? Can you translate that process to
Python?

  As you can see I am having a great problem.

It looks like the normal learning process to me :-)
Just take your time, solve one bit at a time and
build on your previous work. If you get stuck come
back here and ask specific questions and show
us what you have done.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Urgent: Help

2008-01-07 Thread bob gailer
Shumail Siddiqui wrote:
 Dear tutor,
  I have a question regarding a functions based assignment.
I agree with Alan.

And I wonder why this assignment is hard for you.

Are you in the wrong course (insufficient prerequisites)?

Is the instructor failing to provide the resources you need?

Are you overwhelmed with life and struggling to get through?

Or do you just want to get a passing grade and don't care about learning 
programming and Python?

It might help us if we understood why you are seeking help.

Bob


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Urgent: Help

2008-01-07 Thread bob gailer
Please reply to the list not just me. We all participate and learn.

Shumail Siddiqui wrote:
 I know this assignment is not too hard, but I have been greatly 
 overwhelmed with work as I have been taking a 19 credits recently. I 
 kind of have an approach to this by importing random numbers and 
 random.choice leaves the first four numbers as a result. But, I don't 
 know how to add these numbers in the program, 
One approach is:

start with a total of 0
add the first number to the total
if the total does not reach the goal
add the next number
etc.

That can be implemented in a loop.

Give it a try and show us how far you can come.

 while I know that I can use append to add those scores.
I don't know how to use append to add

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor