How We Create Array Element In Python (Hindi)
How We Create Array Element In Python
An array is a special variable, which can hold more than one value at a time.
If you have a list of items (a list of car names, for example), storing the cars in single variables could look like this:
car1 = "Ford"car2 = "Volvo"car3 = "BMW"
However, what if you want to loop through the cars and find a specific one? And what if you had not 3 cars, but 300?
The solution is an array!
An array can hold many values under a single name, and you can access the values by referring to an index number.
Access the Elements of an Array
You refer to an array element by referring to the index number.
cars = ["Ford", "Volvo", "BMW"]
x = cars[0]
print(x)
Modify the value of the first array item:
cars[0] = "Toyota"
The Length of an Array
Use the len() method to return the length of an array (the number of elements in an array).
Return the number of elements in the cars array:
cars = ["Ford", "Volvo", "BMW"]
x = len(cars)
print(x)
Looping Array Elements
You can use the for in loop to loop through all the elements of an array.
Print each item in the cars array:
cars = ["Ford", "Volvo", "BMW"]
for x in cars:
print(x)
? Follow us on our Facebook page
https://www.facebook.com/powerofknowledgein/
? Join our facebook group to get more depth in learning of different technologies
https://www.facebook.com/groups/powerofknowledge/
? Subscribe To Our Channel
https://www.youtube.com/c/PowerofKnowledgein?sub_confirmation=1
? For Suggestions and Help, direct message us on Facebook Messenger
m.me/powerofknowledgein
0:05 introduction of array in python
2:07 access array elements in python
2:48 modify array element in python
3:01 practical session start
#python #arrayinpython
Видео How We Create Array Element In Python (Hindi) автора Кодовое Вдохновение
Видео How We Create Array Element In Python (Hindi) автора Кодовое Вдохновение
Информация
2 декабря 2023 г. 13:28:43
00:06:22
Похожие видео