What is an "array"?

In the Complete Python Mastery course, I have watched the “arrays” video…
But I quite didn’t understand it. And I think Mosh didn’t elaborate it much, and so I didn’t understand :cry: what exactly are arrays and how we use them in PYTHON

Thank you

Hi,
Can you tell me the section and the name of the episode that teaches about array in python course ?

Section: Data Structures
Video : Arrays

Sorry, but i don’t have access to that episode and i couldn’t found the array part in youtube :disappointed:

Watch the video here!
I recorded my screen :sweat_smile:

Hi Megha, I suggest you to visit this link, https://www.thoughtco.com/definition-of-arrays-in-mathematics-2312362
it is going to help you,

Regards,

Jose

Array is a data structure that we use to represent a list of item, but the use case in python is different.
As mosh said in python we usually use lists but if there is a problem in performance or if we’re dealing with a large list of numbers we use arrays because it takes less memory and has a faster performance.

so he imported array class from array module and then defined an array which takes two parameters the first one is about the type which can be a short, integer, float, double, long… and the second parameter is the array itself which is a list of items :disappointed:

from array import array // so from array module he imported array class

array("i", [1, 2, 3])

and after that you can use the methods of that array or you can simply log it using print

@jose_reano this is about arrays in mathematics!

Hi,
i got a problem here in Data strurctures, specially in part 1, Tutorial 4(Exercise Array in class), whenever i try to add new item or try to code the Array, this is going to happen

so please help!
i have been trying for two days by my self but nothing worked

thanks in advance,
Sayidali.

No, you don’t.

@Zabeite First of all: Why are you posting a new Data Structures / Java question in an existing thread in the Python forum?

@Zabeite

  • Mosh named the class Array while you named it Arrays. So the compiler can’t find the Array class you try to use in Main.

  • You seem to have written the parameter names in front of the arguments. Instead of numbers.Insert(items:10) just write numbers.Insert(10).

  • There are syntax errors in your Arrays-class. Fix them before trying to use the class in Main.

1 Like

#first I’m sorrey for posting into a different content but, i was only referring to the Arrays which both courses contain.

although i took every step you mentioned, nothing worked as i expected, am still getiing the same error

Look at the lower left window “Build Output”. It lists the errors you need to fix

  • don’t type parameter names. It’s new Array(3) not new Array(length:3)
  • you have a superfluous “.” in line 7

I’m not sure why your IDE colors the inserts in red. Maybe that’s the way it colors method calls, maybe you have a typo in your Array class. Look how you spelled insert there. Case counts.

In line 7 there are 2 dots and you’ve written the length parameter which is not right so you need to just type 10 and the word length will appear with a small grey text.

Python Arrays