

Python Tutorial to learn Python programming with examples
Complete Python Tutorial for Beginners Playlist :
Python Tutorial in Hindi :
Github :-
In this video we will see:
– Accepting values from user and store them in Array in python
– Creating blank array
– Asking length of array from user and accepting the values
– Printing index of array value manually
– Printing index value of user entered value
– Printing index of array value by function
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
i see everyone using in built function even though assignment says no to those, this is the best answer i could find for the first question
from array import *
arr = array('i',[5,10,22,54,6])
arr = [ e for e in arr if e != arr[2]]
print(arr)
hey ,telusko i want to know that why my command of import all functions from python doesnt work on replit
Assignment
Q 1. To create array with 5 elements and delete element with index value 2.
Q2a) reversing a array without using inbuilt function .b) Creating new array with reversing of existing array
assignment question:
1-create an array with 5 values and delete the value at index number 2 without using in-built function
2-write a code to reverse an array without using in-built function
but one thing sir….
telusko logo and the next video or next series promotions covers the assignment content plz try to uncover it sir…
sir ur python series is the best that i could find on youtube…
may be because of ur clear cut explanation or the way u teach…
sir please bring us with more series in 2020 to improve ourselves and tq somuch for this series sir…
Hi Guys,
Can somebody help?
While I m searching for index of the value always getting 0 , Following is my code and results:
from array import*
arr = array('i', [])
n = int(input("Enter the length of thr array"))
for i in range(n):
x = int(input("Enter the next value"))
arr.append((x))
print(arr)
# If need to know the index of the value
val = int(input("Enter the value for search"))
k = 0
for e in arr:
if e == val:
print(k)
break
k+1
Result:
Enter the length of thr array4
Enter the next value56
Enter the next value34
Enter the next value23
Enter the next value67
array('i', [56, 34, 23, 67])
Enter the value for search23
0
It is impossible to see the assignment questions
Sir the end screens are covering the assignments
•Advice for those who are not able to see questions at last due to channel logo:-
U can just let the video end and turn of auto play option from youtube settings , at last after the video ends you will be able to see questions easily (simple)….
Question 01:-
from array import *
a=array('i',[3,4,5,6,7])
for i in range (5):
if i==2:
continue
else:
print(a[i])
🎯Output:-
3
4
6
7
[Program finished]
Reverse an array program
from array import *
Arr=array('i',[1,2,3 ,4])
new=array(Arr.typecode,(Arr[-i] for i in Arr))
print(new)
#1. Create an array with 5 values and delete the value at index number 2 without using in-built functions.
from array import *
arr=array("i",[13,14,15,16,17])
print(arr)
del arr[2]
print(arr)
#2. Write a code to reverse an array without using in-built functions.
rev=array(arr.typecode,[])
for i in range(len(arr)):
rev.append(arr[len(arr)-i-1])
print(rev)
Really very useful good video👍👍👍👍👍
val=int(input('enter the value'))
for i in range(n):
if val==arr[i]:
print(i)
break
why is i included inside array
The way you say "bye bye" 😂😂
2nd solution
from array import *
arr = array('i',[])
n = int(input("Enter the length of the array"))
for i in range(n):
x = int(input("Enter the next element"))
arr.append(x)
print(arr)
arr.reverse()
print(arr)
1st solution
from array import *
arr = array('i',[])
n = int(input("Enter the length of the array"))
for i in range(n):
x = int(input("Enter the next element"))
arr.append(x)
print(arr)
arr.pop(2)
print(arr)
from array import *
arr =array('i',[])
n = int(input("enter the length of array"))
for i in range(n):
x = int(input("enter the next value"))
arr.append(x)
print(arr)
val = int(input("enter the value to search"))
k = 0
for e in arr:
if e==val:
print(k)
break
K+=1
for all search value its giving index value as '0' only
kindly provied a solution
Sir suppose we have students name and his roll no. Our task is that by searching name find corresponding roll no. How to do that??
is there a way when you are trying to get index number from search instead of using k and incrementing this extra step why not getting index number from the iteration that matches the i == vals : so it could print index of the searched up value.
from array import *
arr = array('i', [])
num = int(input("Enter the length of an array "))
for i in range(num):
n = int(input("Enter the value "))
arr.append(n)
val = int(input("Enter the value for delete "))
c=0
for ele in arr:
if ele == val:
arr.pop(c)
break
c+=1
print(arr)
Program no 2
Arr = array('i', [ ])
X = inter(input("enter the length of array"))
i= 1
For e in range (x+1,1,-1) :
r =int(input(enter the value ))
Arr. Append(r)
For e in range x:
Print(arr.[ x-i] , end= '')
i = i + 1
pls provide the cdes for assignment questions
+
Sir how to take user in put in array in single line?? Like
1 2 3 4 5
1st question:
from array import *
n = int(input('Enter the Number of Elements in Array= '))
arr = array('i',[])
for i in range(n):
x = int(input('Enter the next value= '))
if i==2:
pass
else:
arr.append(x)
print(arr)
2nd question:
from array import *
n = int(input('Enter the Number of Elements in Array= '))
arr = array('i',[])
for i in range(n):
x = int(input('Enter the next value= '))
arr.append(x)
revarr = array('i',[])
for j in range(1,n+1):
revarr.append(arr[-j])
print(revarr)
from array import *
arr=array('i',[])
n=int(input("enter the length of array:"))
for i in range(n):
x=int(input("enter the values:"))
arr.append(x)
print(arr)
len(arr)
vals=int(input("enter the value to search:"))
for e in range(len(arr)):
if arr[e]==vals:
print(e)
from array import *
arr1 = array('i',[])
Len = int(input("Please enter the length of the array:", ))
for i in range(Len):
value = int(input("Please enter the value:", ))
arr1.append(value)
print(arr1)
j = 0
track = int(input("Please enter the number for which index is required:", ))
while(arr1[j]!=track):
j = j +1
print(j)
a quick question on how to know k was define as search numbers? where it has only initialization to zero. It does not tie to search array.
from array import *
arr = array('i',[])
x = int(input("Enter the length of the array you want to create:"))
for i in range(x):
y = int(input("Enter the value for the array:"))
arr.append(y)
print(arr)
k = 0
a = int(input("Enter a value to be searched in arr:"))
for e in arr:
if e == a:
print(k)
break
k+=1
How many of you liked my code? If anyone of you have then please like so that other people could see it.
1)
from array import *
arr = array('i' , [5,6,7,8,9])
print(arr)
k = 0
for e in arr:
if k == 2:
arr.pop(2) # or del arr[2]
k += 1
print(arr)
2)
from array import *
ar = array('i' , [])
n = int(input("Enter the length of the array: "))
for i in range(n):
x = int(input("Enter the next value: "))
ar.append(x)
print(ar)
var = ar[-1::-1]
print(var)
open to feedback on my code and ways to make it more efficient.
2] i) Reversing without built-in function:
from array import *
arr=array('i',[])
l=int(input("Enter size: "))
for i in range(l):
x=int(input("Enter element: "))
arr.append(x)
i=len(arr)
new_arr=[]
while(i!=0):
new_arr.append(arr[i-1])
i-=1
print(new_arr)
ii) Reversing with built-in function:
new=list(reversed(arr))
print(new)
# To create array with 5 elements and delete element with index value 2:
from array import*
arr = array('i',[11,22,33,44,55])
print("length of array is:",len(arr))
print("deleting index 2 value:",arr.pop(2))
print("after deleting index 2 value:",arr)
print("length of array is:",len(arr))
Answer for Q-1 :
from array import *
arr = array('i',[1,2,3,4,5])
length = len(arr)
a=0
for i in range(length) :
if a == 2:
del arr[a]
break
a= a+1
print(arr)
1.
from array import *
arr = array('i',[])
n= int(input("Enter the lengh of array"))
for i in range (n):
x = int(input("Enter the next value"))
arr.append(x)
print(arr)
for i in range (n):
if i ==2:
del(arr[2])
print(arr)
1st solution
Num =array('i',[2,3,4,5,6,]
K=0
For i in num:
if k==2:
pass
else:
print(i)
K+=1
Q. 1
From array import*
X = array("I",[12,34,6,5,8]
#index of 2 is 6
ind = 6
For i in x:
If I==ind:
Continue
Print (i)
#To create an array with 5 elements and delete the element with index value 2
from array import *
arr = array('i',[])
n = int(input("Enter the length of array"))
for i in range(n):
x = int(input("Enter the next value"))
arr.append(x)
print(arr)
k = int(input("Enter the index of the value you need to delete"))
for e in arr:
del arr[k]
break
print(arr)