Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

zeros() python function is undefined

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
F37U5G0D
Posts: 102
Joined: 2008-07-27 01:30
Location: Monmouth, Il
Been thanked: 2 times

zeros() python function is undefined

#1 Post by F37U5G0D »

When I run my code zeros ([7,7], int) I get the error that the zeros() is undefined even though I have the numpy package installed. What gives?

User avatar
BioTube
Posts: 7520
Joined: 2007-06-01 04:34

Re: zeros() python function is undefined

#2 Post by BioTube »

Did you remember to import the proper package/library/whatever?
Image
Ludwig von Mises wrote:The elite should be supreme by virtue of persuasion, not by the assistance of firing squads.

F37U5G0D
Posts: 102
Joined: 2008-07-27 01:30
Location: Monmouth, Il
Been thanked: 2 times

Re: zeros() python function is undefined

#3 Post by F37U5G0D »

Yeah my code starts with

Code: Select all

import string, sys, random, array, Numeric, numpy
I don't get any errors on that line yet zeros(anything) throws an error everytime.

lacy1809
Posts: 1
Joined: 2019-03-09 00:52

Re: zeros() python function is undefined

#4 Post by lacy1809 »

Hello All,

I am newbie to python. And i'm practicing at home to see the youtube videos.
I was trying to use a=zeros(5) in python, but getting the error. Please check it and help me to solve

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'zeros' is not defined

Please help me with this or suggest me any of the python tutorial where i can learn the deep concept of python.

Thanks in advance!

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: zeros() python function is undefined

#5 Post by GarryRicketson »

Please check it and help me to solve
You can try to check it like this:
Python function undefined NameError: name 'zeros' is not defined
The first hit, is almost identical to what you posted, maybe it was you or you copied / pasted the same to here ???
https://bytes.com/topic/python/answers/ ... ot-defined
Says you need to use "numpy",
Please help me with this or suggest me any of the python tutorial where i can learn the deep concept of python
In the same results, there is this.

https://docs.python.org/3.3/tutorial/introduction.html
Please make some effort to learn how to help your self, I will give you 1 more example, to help you get started.
python tutorial where i can learn the deep concept of python
You should see there are many results, there are many good tutorials, if for some reason you can not do searches on your own, or don't get any good results, maybe I will post some of the links here,..also, do you realize this thread is 10 years old ? No matter, now it will be more up to date.
The first hit, looks pretty good: https://docs.python-guide.org/intro/learning/
If you don't like that one, try some of the others, and please, in the future try to make a little effort to search for answers, and tutorials, learn how to help your self.
Maybe read this:
"What we expect you have already Done"

Post Reply