# #26 Python Tutorial for Beginners | Array in Python

///#26 Python Tutorial for Beginners | Array in Python
• ## #26 Python Tutorial for Beginners | Array in Python  Add to favorites

Python Tutorial to learn Python programming with examples
Complete Python Tutorial for Beginners Playlist :
Python Tutorial in Hindi :

In this video we will see:
– Why Array?
– Advantage of Array in Python
– When to use Array
– Importing module
– Creating Array
– Type of array
– Type code
– Storing value in array
– Printing array values
– buffer_info function
– Printing type code
– reverse function
– Printing value of specific index
– Printing values using loop
– Printing length of array
– Creating array of unicode value
– Creating new array by copying existing array
– Copying type from old array

Editing Monitors :

Check out our website:

Follow Telusko on Twitter:

Follow on Facebook:
Telusko :
Navin Reddy :

Follow Navin Reddy on Instagram:

Subscribe to our other channel:
Navin Reddy :
Telusko Hindi :

Donation:
PayPal Id : navinreddy20
Patreon : navinreddy20

source

By |2019-08-16T22:05:26+00:00August 16th, 2019|Python Video Tutorials|28 Comments

### 28 Comments

1. Rs Chudasama August 16, 2019 at 10:05 pm - Reply

1st Assignment:
vals=array('i',[1,2,5,3,6])
newarr=sorted(vals)
print(newarr)

2nd Assignment:
from math import *
num=int(input('Enter a number')
print(factorial(num))

2. varun krishna kyathanpally August 16, 2019 at 10:05 pm - Reply

2nd quiz question answer
x = input("enter the number for the factorial")

i = 1

fact = 1

while i<x:

fact = fact * x

x = x-1

print (fact)

3. Agathiyan Janardhana August 16, 2019 at 10:05 pm - Reply

problem 2

a=int(input('number for factorial'))

fact=1

for i in range(1,a+1):

fact=fact*i

print(fact)

4. Saritha Bathini August 16, 2019 at 10:05 pm - Reply

Thank you very much for your valuable videos on python..it's simply amazing. You made Python very simple and easy to understand. Once again thank you for your effort.

5. shaukat khattak August 16, 2019 at 10:05 pm - Reply

array code does not work in my pycharm why i write as same as you sir

6. Vikram Krishna August 16, 2019 at 10:05 pm - Reply

excellent explanation sir especially while saying about coping array values into a new array

7. Srinivas Ramachandran August 16, 2019 at 10:05 pm - Reply

from array import *

vals = array('i',[1,10,3,4])

for a in vals:

b = 1

for a in range(1,a+1):

a=a*b

b=a

print(a, end='')

print()

8. alek 126 August 16, 2019 at 10:05 pm - Reply

Second
I = int(input("gimme a num"))
e=1

While I>0
e=e*I
I=I-1
Print(e)

9. SOUBATHA T August 16, 2019 at 10:05 pm - Reply

#1
num=int(input("Enter a number:"))
z=1
for i in range(1,num+1)
z=i*z
print(z)

10. Onkar Pawar. August 16, 2019 at 10:05 pm - Reply

1. A code to sort the array in ascending order
alphabets = array('u', ['a', 'q', 'b', 'k', 'z', 'f'])

print(sorted(alphabets))

nums = array('i', [55, 7, 0, 65, 20, 34])

print(sorted(nums))

2. A code to find the factorial of given number
fact = array('i', [2, 5, 3, 7])

for f in fact:

print(factorial(f))

11. FitnessKanacke August 16, 2019 at 10:05 pm - Reply

You are a very good teacher. Love your Python tutorials! Thank you!!

12. Rtk Soni August 16, 2019 at 10:05 pm - Reply

sir im enjoying the python course
you are doing such A GRAET WORK

13. sainathreddy gangireddy August 16, 2019 at 10:05 pm - Reply

Love you sir ji🙏🙏..I am enjoying your teaching ❤

14. Krishna Jadhav August 16, 2019 at 10:05 pm - Reply

India needs more teacher like u….we pay laks of fees to clg and learns nothing .

15. Riyaz mhd August 16, 2019 at 10:05 pm - Reply

1.from array import *
arr=array('i', [3,2,6,1])
print(sorted(arr))
2.n=int(input("enter the input"))
fact=1
for i in range(1,n+1):
fact=fact*i
print(fact)

16. honey sharma August 16, 2019 at 10:05 pm - Reply

pls do reply me navin .I HAD A DOUBT THAT ,,LETS 'A' BE AN ARRAY ,
CAN WE DO LIKE THIS
A=ARRAY('U',[1,2,3])
B=A
IN THIS CASE ADDRESS OF BOTH ARE SAME,,,
B=ARRAY('U',[1,2,3]),
HERE ADDRESS ARE DIFFERENT ,,BUT THEY SHOULD BE SAME NO,,AS EARLIER YU TAUGHT THE CONCEPT OF OBJECT ,,
b=array(a.typecode,(a for a in a))
HERE ALSO ADRESS ARE DIFFERNT BUT AGAIN SHOULD BE SAME,,PLS REPLY ,I HAD BEEN MESSED UP….

17. vivek kumar sharma August 16, 2019 at 10:05 pm - Reply

# Factorial number
nums = int(input("Enter the factorial number >> "))
fact = 1
for num in range(1,nums+1):
fact = num * fact
print(fact)

18. vivek kumar sharma August 16, 2019 at 10:05 pm - Reply

from numpy import *
arr = array([2,3,56,5,7],int)
for i in range(len(arr)):
for j in range(4-i):
if arr[i] > arr[i+1]:
temp = arr[i]
arr[i] = arr[i+1]
arr[i+1] = temp
print(arr)

19. Aniket Kashyap August 16, 2019 at 10:05 pm - Reply

1st answer:-
From array import *
arr=array('u',[‘a’,’r’,’r’,’a’,’y’])
arr1=sorted(arr)
for i in arr1
print(i)

2nd answer

Import math
Val=int(input(‘enter value’))
Print(math.factorial(val))

20. Y Shreyas August 16, 2019 at 10:05 pm - Reply

for factorial
x=int(input("enter a number you want"))
fact=1
for i range(x,1,-1):
fact=fact*i
print(fact)

21. Y Shreyas August 16, 2019 at 10:05 pm - Reply

can anybody tells me how to arrange elements in an array in ascending order?

22. Om Choudhary August 16, 2019 at 10:05 pm - Reply

In 14:27 what is the connection of 'a' with vals ??😕. What does 'a' mean ??

23. Baljot Singh Choudhary August 16, 2019 at 10:05 pm - Reply

Can we use newarr=val[:]

24. Prince Vegeta August 16, 2019 at 10:05 pm - Reply

For Question #2, without importing math

x = int(input('pick a number to find its factorial '))

y = x

i = 0

while True:

i+=1

if i == y:

print(x)

break

x = x * (y – (i))

—-

feel free to give feedback

25. Prince Vegeta August 16, 2019 at 10:05 pm - Reply

I see many people using sorted for first question.
This is one way of doing it without using sorted:

from array import *

ara = array('i', [5, 6, 2, 8,])

x = 0

while True:

x+=1

for i in ara:

if i == x:

print(i)

if x > max(ara):

break

however, negative numbers don't work. Can anyone point in the right direction to do it the long way without using sorted.

And as always never stop teaching Navin, you have special talent.

26. Gaurao Mate August 16, 2019 at 10:05 pm - Reply

Factorial
import math

val=math.factorial(23)

print("The factorial is",val)
The factorial is 25852016738884976640000

27. Binay Mohanta August 16, 2019 at 10:05 pm - Reply

import math

x=int(input('enter the value:'))

if x==0:

print("Factorial is: 1")

else:

for i in range(1,x):

x=x*i

print("Factorial is:",x)

28. Fahim Rahman August 16, 2019 at 10:05 pm - Reply

For Floating type my code is:

import array as a

cgpa = a.array('f',[2.87,3.06,3.03,3.21,3.06,3.06])

for n in cgpa:

print(n)

I got output:
2.869999885559082
3.059999942779541
3.0299999713897705
3.2100000381469727
3.059999942779541
3.059999942779541

why i'm getting extra digits after the floating point?