473,320 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

NameError: name 'b' is not defined

Expand|Select|Wrap|Line Numbers
  1. >>> import numpy
  2. >>> def backsub(X, y):
  3.     l = shape(X)  
  4.     n = l[1]
  5.     X = mat("1. 2. 3.; 0. 3. 2.; 0. 0. 1.")
  6.     y = mat(" 2.; 4.; 5.")
  7.     b = zeros((n,1))
  8.     b[n-1, 0] = y[n-1, 0]/X[n-1, n-1]
  9.     for j in range(n-1,0,-1):
  10.         b[j-1,0] = (y[j-1,0] - dot(X[j-1, range(j,n)], b[range(j,n),0]))/X[j-1, j-1]
  11.     return b
  12. print (b)
Sep 7 '15 #1
2 4199
dwblas
626 Expert 512MB
You should be able to debug this yourself by adding a few simple print statements to see what is executing and what is not. No offense intended, but it is a waste of everyones time to post this, and you don't want people ignoring your questions because they were like this one in the past. Post back if you can't find the error, posting the complete error message and code that shows that you have attempted to find the problem yourself.
Sep 7 '15 #2
dwblas
626 Expert 512MB
And if you keyed this into the python interpreter on the console, use a text editor, https://wiki.python.org/moin/PythonEditors or IDLE (comes with python) so you can save the file, change it, run it again, etc.
Sep 7 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Martin Drautzburg | last post by:
Withing a module I can assign a value to a global var by assigning to it in the outermost scope. Fine. But how can I do this if the attribute name itself is kept in a variable. Once the module...
2
by: jolly | last post by:
hey guys, When i try to run my code I get an error. NameError name 'main is not defined' if __name__ == "__main__": main() filename = "addbook.dat"
3
by: willkab6 | last post by:
I am very new to both programming and Pyhton and while trying to do some practice using A byte of python an Error pops up on the IDLE shell. I am using windows XP. PLease see below. while running:...
1
by: tshravan | last post by:
Hello All, I am newbie to python. I was trying to use a=zeros(5) in python shell, but it is throwing the following exception in the shell Traceback (most recent call last): File...
1
by: manojnkumar | last post by:
#This is to add, sub, mul and div using functions def menu(): print "" print "Welcome to the calculator" print "===== These are some of the options =====" print "1-->...
3
by: Mathieu Prevot | last post by:
Hi I import subprocess and use Popen, but PIPE is not defined. I used 2.5.1, 2.5.2, Python 2.6a3+ (trunk:63576, May 24 2008, 12:13:40), it's always the same. What am I missing ? Thanks...
3
by: cirfu | last post by:
im doing the python challenge and well, i solved this problem with ruby :) phrase = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb...
4
by: Harry | last post by:
Hi there. I am trying to download a file(sn.last) from a public FTP server with the following code: from ftplib import FTP ftp=FTP('tgftp.nws.noaa.gov') ftp.login()...
4
by: harijay | last post by:
Hi I am new to writing module and object oriented python code. I am trying to understand namespaces and classes in python. I have the following test case given in three files runner , master and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.