L 23: ARRAYS IN PYTHON | ARRAY OPERATIONS IN PYTHON | PYTHON TUTORIALS FOR BEGINNERS

Опубликовано: 01 Январь 1970
на канале: Parnika Tutorials
923
27

The array module allows us to store a collection of numeric values.
Creating Python Arrays:
To create an array of numeric values, we need to import the array module. For example:
import array as arr
a = arr.array('d', [1.1, 3.5, 4.5])
print(a)

Accessing Python Array Elements:
We use indices to access elements of an array.
import array as arr
a = arr.array('i', [2, 4, 6, 8])
print("First element:", a[0])
print("Second element:", a[1])
print("Last element:", a[-1])

Slicing Python Arrays:
We can access a range of items in an array by using the slicing operator :
import array as arr
numbers_list = [2, 5, 62, 5, 42, 52, 48, 5]
numbers_array = arr.array('i', numbers_list)
print(numbers_array[2:5]) # 3rd to 5th
print(numbers_array[:-5]) # beginning to 4th
print(numbers_array[5:]) # 6th to end
print(numbers_array[:]) # beginning to end

Changing and Adding Elements:
Arrays are mutable; their elements can be changed in a similar way as lists.
import array as arr
numbers = arr.array('i', [1, 2, 3, 5, 7, 10])
changing first element
numbers[0] = 0
print(numbers) # Output: array('i', [0, 2, 3, 5, 7, 10])
changing 3rd to 5th element
numbers[2:5] = arr.array('i', [4, 6, 8])
print(numbers) # Output: array('i', [0, 2, 4, 6, 8, 10])

Removing Python Array Elements:
We can delete one or more items from an array using Python's del statement.
#ARRAY #PYTHON #PARNIKATUTORIALS
00:00 Introduction
00:29 Limitation of a variable
01:21 What is an array
02:15 How to import array module
05:19 How to compute length of an array
09:26 How to add elements in an array
14:25 How to remove elements in an array
17:26 How to concatenate two arrays
19:37 Slicing in an array
22:15 Displaying elements in an array
26:16 Implementation in Jupyter Notebook
Website: www.parnikatutorials.in
Email id: [email protected]
To get the regular updates:
Telegram link: https://t.me/Parnikatutorials

Facebook: https://m.facebook.com/profile.php?id...
Linkedin:   / parnika-tutorials-a8a9831b2  
Pinterest:   / parnikatutorials0892  
Instagram:   / parnikatutorials  
Playlists:
Virtual Coffee with Jagadeesh:    • VIRTUAL COFFEE WITH JAGADEESH  
Digital Logic:    • ABOUT PARNIKA TUTORIALS  
Computer Organization and Architecture:    • ABOUT PARNIKA TUTORIALS  
C Programming:    • L 1: WHAT IS AN ALGORITHM AND CHARACT...  
Data Structures:    • L 1: Uncover the Benefits of Linked L...  
Theory of Computation:    • ABOUT PARNIKA TUTORIALS  
Compiler Design:    • ABOUT PARNIKA TUTORIALS  
Operating Systems:    • PROCESS STATE DIAGRAM | LONG TERM, SH...  
Databases:    • ABOUT PARNIKA TUTORIALS  
Computer Networks:    • ABOUT PARNIKA TUTORIALS  
For GATE PYQs and much more explore:    / parnikatutorials  
TAGS:
WHILE LOOP
WHILE LOOP IN PYTHON
PYTHON TUTORIALS FOR BEGINNERS
FLOWCHART OF WHILE LOOP
WHAT IS A FLOWCHART
ITERATIVE STATEMENTS IN PYTHON
FREE LECTURES OF PYTHON
PYTHON COURSE FOR BEGINNERS
ITERATIVE STATEMENTS IN PYTHON
BEST PYTHON COURSE
BEST PYTHON COURSE FOR FREE
PARNIKA TUTORIALS
PYTHON PROGRAM TO COMPUTE SUM OF N NATURAL NUMBERS
HOW TO WRITE PYTHON PROGRAM TO COMPUTE SUM OF FIRST N NATURAL NUMBERS
FOR ELSE IN PYTHON
FOR ELSE STATEMENT IN PYTHON
FOR ELSE WITH AN EXAMPLE IN PYTHON
Factorial program using for loop
How to write python program to find factorial of a number
what is factorial of a number
Break vs continue vs pass in python
Break statement in python
Continue statement in python
pass statement in python
Need for pass statement in python
Break, continue, & pass in python