#27 Python Tutorial for Beginners | Array values from User in Python | Search in Array

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO20 (20% Discount)

Coupon: TELUSKO20 (20% Discount)

Udemy Courses:

For More Queries WhatsApp or Call on : +919008963671

In this lecture we will learn:
- How to create an empty array?
- How to create an array through user input?
- Array creation by taking the values from a user
- How to search an element in an array?
- Function used to get the index value of an element in python

#1
- We can also create a blank array and can take the values for it from the user.
- First, we have to take the length of an array from the user.
- input() function takes the value in the form of a string, so we have to change it into an integer using int().
- We can run a loop in a range of length of an array given by the user. At each iteration, we can take a value to be inserted in an array.
- append() is a function that is used to add a value or an element in an array.

#2
- To search for any value in an array or to check the index number at which the value is present, we need to increment the value of an iterator variable in every iteration.
- When the condition of comparison gets true, we stop the loop to iterate further and print the value of an iterator variable.
- The iterator variable will return an index number of the value, you have searched for.

#3
- index() function can also be used to get the index number of a value in an array.

Editing Monitors :

Subscribe to our other channel:
Telusko Hindi :

Donation:
PayPal Id : navinreddy20
Patreon : navinreddy20
Рекомендации по теме
Комментарии
Автор

Those who can not see the assignment due to Playlist in front of questions.. The assignment que. is:
1) Create an array with 5 values & delete the value at index no. 2 without using in-built function.
2) write a code to reverse an array without using in-built function.

priyanshupatel
Автор

i do competitive coding, whenever i get confused with basic fundamentals, your channel is where i land. thanks bro . 🙌

nishantsharma
Автор

Hi Navin Reddy, thank you so much for the sessions.
1)
# To create array with 5 elements and delete element with index value 2:
from array import *
arr = array('i', [])
#
len = int(input("Enter length of array:"))
#
for i in range(len):
ele = int(input("Enter elements:"))
arr.append(ele)
print(arr)
#
for d in range(len):
if d == 2:
arr.pop(d)
print(arr)
# OR
for d in range(len):
if d == 2:
del arr[2]
print(arr)

2.a) Reversing array:
from array import *
arr = array('u', ['a', 'b', 'c', 'd'])
len = len(arr)
#
for i in range(int(len/2)):
temp = arr[i]
arr[i] = arr[len-i-1]
arr[len-i-1] = temp
print("The reversed array is:", arr)

2.b) Creating new array with reversing of existing array:
from array import *
#
arr = array('u', ['a', 'b', 'c', 'd'])
#
len = len(arr)
arr1 = array(arr.typecode, [])
#
i = 1
while i <= len:
arr1.append(arr[4-i])
i+=1
print(arr1)

sathishkumars
Автор

the way he says "bye bye " at the end of the video makes me to feel something special....

FonxyStar
Автор

You are one of the best teachers for the programming language.
Go a head.

ramarashdi
Автор

NaveenBhau, I'm Binge watching your PythON series since this morning. They are quite good. Thanks and Greetings from Switzerland.

mrniceguy
Автор

# Second Program
from array import *
arr = array('i', [10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
print(arr[::-1])

piyushbadule
Автор

1). question
from array import*
arr=array ('i', [1, 2, 3, 4, 5])
for i in arr:
if i==arr[2]:
continue
print (i)

nagababuthepython
Автор

Hi sir! Just wanted to say your videos are inspiring and to the point. Love them.

abhinavs
Автор

yup this quarantine is python's by Navin sir
by the way, they are amazing

dineshnandyala
Автор

'''answer for the first question'''
import array as a
arr=a.array("i", [])
lent=int(input("Enter the length of array : "))
for i in range(lent):
val=int(input("Enter the elements of array one by one and press enter"))
arr.append(val)
print(arr)
arr2=a.array('i', [])
del_elm=int(input("Enter the element you wish to remove/delete : "))
for element in arr:
if del_elm==element:
continue
else:
arr2.append(element)

print("The new array is : \n", arr2)

thatguyadarsh
Автор

In my quest to learn Python and to start from basic, I went to google to understand OOP concept a week back and got to your channel purely by chance...That session was truly awesome, which brought me to your series on Python and I could simply say that I am loving it, every single minute is a learning, shared your details with many of my friends and colleagues...You have really great teaching skills..Good Teacher could be a good programmer but every good programmer can not be a good Teacher...THANKS

biasnitin
Автор

Navin sir, I just want to say thank you for this knowledge that you're providing us. Hats off🙏🏻🙏🏻

shubhankursharma
Автор

Hi, there are so many channels in youtube for python tutorials, but the way you describe its uniqe and very understable. keep the pace.

shashanksharma
Автор

i can not see the assignment question on assignment question his playlist and channel logo pops up

hassnainamjad
Автор

# code for 2nd Q, s
from array import *
arr = array("i", [ ])
for i in range(4):
x = int(input("Enter the value: "))
arr.append(x)
print(arr)
b = array('i', [])
for i in range(4):
b.append(arr[-(i+1)])
print(b)

ranjithkumarneeruganti
Автор

Hello!
Your videos are great. Just one suggestion: At the end of every video, the pop-ups about your previous video and the Telusuko logo actually block the assignment questions. So, can you pls type the assignment question in the description as well, or maybe you have a better solution? But I personally feel you have to do something about it.
Thank you
Great work :)

soundharyav
Автор

Sir ji TUSSI GREAT HO. College time me kabhi coding nahi sikhi or nahi kabhi mann kiya but jab 5 saal baad lga mechanical me bhi coding important h and then I thought, let's give it a try.
My brother and one friend suggested your channel and after going through your videos I never felt like coding is difficult. From your course, I realized that the only thing required for coding is logic. More you apply logic, more simpler will be a language. Really thankyou for efforts and HATS OFF to your energy while expalining! Love you pal :)

rohitgoel
Автор

Not able to see the assignment question at the end of these videos, It is hidden by Django playlist

skjnas
Автор

1.
from array import *
arr = array('i', [])
for i in range(5):
x= int(input("enter values"))
arr.append(x)
print(arr)
numbers=arr
print("Deleted element is :", numbers.pop(2))
print("Current elements are:", numbers)
2.
from array import *
arr = array('u', [])
for i in range(5):
x= (input("enter character"))
arr.append(x)
print("Before Reversing Array:", arr)
arr.reverse()
print("After reversing Array:", arr)

Thank You Sir...Love from West Bengal...and sir now i realized that my time at the lock down was not wasted.

avishekmandal