#30 Python Tutorial for Beginners | Copying an Array in Python

Sdílet
Vložit
  • čas přidán 5. 09. 2024
  • Check out our courses:
    Spring and Microservices Weekend Live Batch : bit.ly/spring-...
    Coupon: TELUSKO10 (10% Discount)
    Master Java Spring Development : bit.ly/java-sp...
    For More Queries WhatsApp or Call on : +919008963671
    website : courses.telusk...
    Instagram : / navinreddyofficial
    Linkedin : / navinreddy20
    TELUSKO Android App : bit.ly/TeluskoApp
    Discord : / discord
    In this lecture we will see:
    - Addition of values in an array
    - Different functions that can be performed on arrays
    - What is Aliasing in python?
    - Different ways of copying an array
    #1
    - We can add any value in each element of an array.
    - We can also add values of two arrays.
    - The addition of two arrays is known as Vectorized Operation.
    - We can also find the values of each element of an array of mathematical operations such as sin, cos, tan, log, sqrt etc.
    - Sum of every element of an array can also be calculated by using the sum() function.
    - Minimum value can also be get from an array through the min() function.
    - Maximum value can be get from an array by using the max() function.
    - Unique elements from an array and the sorted array can also be get.
    - Concatenation of two arrays can also be performed by using the concatenate function. This function combines two arrays.
    #2
    - Two variables can be pointed towards a single array. It means both variables are pointing to the same memory address where the array is stored.
    - In Python, Aliasing happens whenever one variable's value is assigned to another variable.
    - view() is a function that helps to create a new array at a new location. It means arrays should be present at the different memory addresses.
    - By using the view() functions, two variables will point towards two different arrays.
    #3
    - In python, two copying techniques are available i.e.,
    1. Shallow Copy
    2. Deep Copy
    - In shallow copy, it will copy elements but it means both arrays are dependent on each other.
    - In shallow copy, if we update an element in one array then the changes would also be reflected in another array.
    - In a deep copy, two different arrays are not linked with each other in any way.
    - In a deep copy, we use the function known as a copy() instead of using the view() function.
    - copy() function provides a deep copy of an array.
    Github :- github.com/nav...
    Python for Beginners :- bit.ly/3JOLQhl
    Java and Spring Framework For beginners with Spring Boot : - bit.ly/3LDMj8D
    Java Tutorial for Beginners (2023) :- bit.ly/3yARVbN
    Subscribe to our other channel:
    Navin Reddy : www.youtube.co....
    Telusko Hindi :
    www.youtube.co....
    Donation:
    PayPal Id : navinreddy20
    Patreon : navinreddy20
    www.telusko.com...

Komentáře • 912

  • @fazlurrehmanejazahmad6068
    @fazlurrehmanejazahmad6068 Před 4 lety +135

    I am a mechanical engineer,
    Just heard of this language, searched for online tutorials, guess what ? I count myself lucky to learn from your tutorial
    Thanks sir,
    Jazakallah khair 🙂

  • @manojgokhale9235
    @manojgokhale9235 Před 4 lety +12

    Not all superheroes wear capes, Some teach Python for free...

  • @amitmiskin6396
    @amitmiskin6396 Před 4 lety +23

    Hello Navin sir, Although i am from a software background, I always had this fear of coding and use to run away from it. Since i have started watching your videos now i feel confident and now i am beginning to write some lines of code on my own. Still long way to go! I have my MS studies coming up and i desperately needed to learn a language. I dont know how would i do that if i had not come across your channel. In kannada, there is a saying "Koti Koti Dhanyavadagalu" meaning countless thanks for changing my life :)

    • @akash6327
      @akash6327 Před 3 lety +3

      hey.. nanu kuda kannadiga bro :)

  • @danielkamau8436
    @danielkamau8436 Před 4 lety +38

    Waoh Sir Navin, who is like me in this am humbled to say I got 100% in this

  • @OgabekToshniyozov-kl2zs
    @OgabekToshniyozov-kl2zs Před 10 měsíci +5

    Hello Mr.Navin. Thank you so much for sharing valuable and interesting videos for us. I've started to learn Python by watching and practising your videos and everything is Ok.

  • @farnaazkhan2134
    @farnaazkhan2134 Před 6 lety +29

    finally I got deep and shallow copy from your videos....before I searched on web n didn't get ….thank you sir.....

  • @entertainmentcenter6727
    @entertainmentcenter6727 Před 4 lety +14

    from numpy import *
    arr =array([1,2,3,4,25])
    arr1=array([15,16,20,21,5])
    for i in range(len(arr)):
    arr[i]=arr[i]+arr1[i]
    print(arr)
    print("bye")

    • @madhankumarmr9968
      @madhankumarmr9968 Před 3 lety

      Bhai if length is not same means wt to do can u please guide me

    • @namanjain2320
      @namanjain2320 Před 3 lety +2

      @@madhankumarmr9968
      from numpy import *
      arr1=([3,7,8,4,3])
      arr2=([8,3,9,6])
      arr3=([])
      for i in range(min(len(arr1),len(arr2))):
      x=arr1[i]+arr2[i]
      arr3.append(x)
      print(arr3)

    • @mahirlabib9005
      @mahirlabib9005 Před 3 lety +2

      @@namanjain2320 cant append in numpy

    • @vedantdhote649
      @vedantdhote649 Před 2 měsíci

      Numpy doesn't support append method

  • @shubhamkadam7224
    @shubhamkadam7224 Před 4 lety +1

    i m a it student...and python is one of the trending languages...i went for too many channels on youtube...but i found urs is very helpful and relying...one of ur instructor helped through ur tutorials to make me learn javascript...keep it up you all guys u r doing great work and i always wish for your best guys...

  • @just_a_living_being
    @just_a_living_being Před 6 lety +9

    thank you Sir : )
    Ans:
    1.
    from numpy import *
    array1 = ([])
    array2 = ([])
    size1 = int(input('Enter size of first array: '))
    size2 = int(input('Enter size of second array: '))
    print(f'Enter {size1} values in first in array: ')
    for i in range(size1):
    array1.append(int(input()))
    print(f'Enter {size2} values in second array: ')
    for i in range(size2):
    array2.append(int(input()))
    if size1 < size2:
    for i in range(size1):
    array2[i] = array1[i] + array2[i]
    print(array2)
    else:
    for i in range(size2):
    array1[i] = array1[i] + array2[i]
    print(array1)
    2.
    from numpy import *
    array = ([])
    size = int(input('Enter size of array: '))
    print(f'Enter {size} values in array: ')
    for i in range(size):
    array.append(int(input()))
    max_value = array[0]
    for i in range(1, size):
    if max_value < array[i]:
    max_value = array[i]
    print(f'Maximum value = {max_value}')

    • @abhishekaj2376
      @abhishekaj2376 Před 5 lety

      Bhai ye print ke Baad f likha hai wo q likha hai (f'Maximum value ) isme jo f hai wo

    • @naturearoundme5686
      @naturearoundme5686 Před 5 lety

      Great!

    • @roger2749
      @roger2749 Před 5 lety

      your code doesn't work on my system bro, can you plz explain the code

    • @sumanshu.nankana
      @sumanshu.nankana Před 5 lety

      This is not an Array, You are adding two lists. Check the type of variables 'array1' and 'array2'

    • @sagnikray5391
      @sagnikray5391 Před 5 lety +2

      bhai numpy main append attribute nahi ata hai

  • @MrObadebella
    @MrObadebella Před 7 dny

    qn 1,
    from numpy import *
    arr1 = array([2,4,5,6])
    arr2 = array([3,7,9,1])
    for arr3 in (arr1 + arr2):
    print(arr3)
    qn2,
    from numpy import *
    arr = array([2,4,7,1,2])
    max = 0
    for i in range(len(arr)):
    if(max

  • @ashish2099
    @ashish2099 Před 4 lety +8

    man, you're the best teacher I've come across. Best tutorials. Bought some paid ones on udemy, neither lived up to expectations. The content here, super.... Engaging delivery......

  • @user-wx5tq3oj8x
    @user-wx5tq3oj8x Před 11 měsíci +4

    #1
    from numpy import *
    arr1 = array([5, 10, 15, 20, 30])
    arr2 = array([55, 16, 1, 280, 60])
    arr3 = []
    k = 0
    for num1 in arr1:
    num3 = num1 + arr2[k]
    arr3.append(num3)
    k += 1
    print(arr3)
    #2
    def find_max(array):
    max_value = array[0]
    for i in range(1, len(array)):
    if array[i] > max_value:
    max_value = array[i]
    return max_value
    array = [3, 5, 7, 2, 9, 4, 6]
    print("The max value in the array is", find_max(array))

  • @bisrata.9999
    @bisrata.9999 Před 2 lety +7

    1) from numpy import *
    a=array([1,2,3,4,5])
    b=array([6,7,8,9,10])
    c=array([i for i in a + [j for j in b]])
    print(c)

  • @sreecharan4300
    @sreecharan4300 Před 5 lety +5

    i am absolutely loving it sir. you teach to the point and every minute i spend here feels like i am learning something new.a big thanks for your effort.

  • @Sandythecoder1010
    @Sandythecoder1010 Před 4 lety +10

    Q2.
    max = 0
    for i in range(len(arr1)):
    if(max

    • @Cristiano_Ronaldo_28_17_7
      @Cristiano_Ronaldo_28_17_7 Před 3 lety

      its working but can u please explain it

    • @Sandythecoder1010
      @Sandythecoder1010 Před 3 lety +1

      @@Cristiano_Ronaldo_28_17_7 what we are doing here is - we are traversing the list (arr1) element one by one.
      In the if condition we are checking that does current element have greater value than max variable have ?
      If yes than we will store the value of current element in max variable else continue traversing the list i.e. next element
      And at the end we are printing max variable value.

    • @Cristiano_Ronaldo_28_17_7
      @Cristiano_Ronaldo_28_17_7 Před 3 lety

      @@Sandythecoder1010 thank you now I got it

    • @jabi24
      @jabi24 Před 2 lety

      Thankyou

  • @shraddhadhawan7685
    @shraddhadhawan7685 Před 4 lety +3

    You make learning really very easy.It is because of you that I developed interest in learning something new.
    Thank You a Lot!!

  • @rithishreddy592
    @rithishreddy592 Před 3 lety +6

    Don't know whether it's the best answer but as a beginner I feel good somewhat now.
    #1)Write a code to add 2 arrays using forloop.
    from numpy import *
    arr1=[1,2,3,4,5]
    arr2=[3,1,8,9,4]
    arr=[]
    for i in range(len(arr1)):
    a= arr1[i] + arr2[i]
    arr.append(a)
    print(arr)
    #2)Write a code to find the maximum value from an array without using in-built fuction
    arr=[121,54,78,343,269,313]
    temp_max=arr[0]
    for i in range(len(arr)):
    if arr[i]>temp_max:
    temp_max=arr[i]
    print(temp_max)

    • @akshayak4007
      @akshayak4007 Před 2 lety +2

      For numpy , append doesnt work

    • @YashhC
      @YashhC Před rokem

      Just use array module instead of numpy here. Append won't work for numpy
      The one you made isn't an array btw, an array has to be defined as array([elements]). That's why append is working for you in this code

    • @YashhC
      @YashhC Před rokem

      Great logic for max btw!

  • @chughprabhkirat4141
    @chughprabhkirat4141 Před 4 lety +8

    #1. add two arrays using for loop
    from numpy import *
    arr1 = array([1,2,3,4,5])
    arr2 = array([12,12,12,2,2])
    for i in range(len(arr1)):
    sum = arr1[i]+arr2[i]
    print(sum)
    #2. find maximum value from array without using in-built function
    from numpy import *
    arr = array([23,12,56,90])
    max = arr[0] #suppose value at 0 index is the greatest
    for i in range(len(arr)):
    #compare
    if arr[i]>max: #print(arr[i]) ----- print the values present at a particular index
    max = arr[i]
    print(max)
    #3. add 5 to each element of an array using for loop
    from numpy import *
    arr = array([15,2,55,4,5])
    for i in range(len(arr)):
    res = arr[i]+5
    print(res)

    • @yeruvasaikrishna8182
      @yeruvasaikrishna8182 Před 2 lety

      great work

    • @chitranjansingh8432
      @chitranjansingh8432 Před rokem

      Kind of late but in solution of 1. you are not checking which arr is greater. if len of arr1 is greater your code will fail. Been 3 years not sure where you are or if you are even doing python lol.
      but this code will work in any case:
      arr1 = ([1,2,3,4,5])
      arr2 = ([1,2,3,4])
      if len(arr1)

    • @user-gj6kk2jo6c
      @user-gj6kk2jo6c Před rokem

      @@chitranjansingh8432 your assumption is wrong... And we don't need to use this, as the inputs of arr1 and arr2 are given by us... Your code is usable when we take the inputs of arr1 and arr2 from an user....

    • @dharmakdgk6517
      @dharmakdgk6517 Před 9 měsíci

      I didn't get it can u plzz explain this.

  • @chanduv8109
    @chanduv8109 Před 4 lety +8

    Adding 5 in single array set
    from numpy import *
    arr=array([1,2,3,4,5])
    for i in range (5):
    print(arr[i]+5)

    • @kamaleshg3944
      @kamaleshg3944 Před 2 lety

      use break key at the end or else it will print five times

  • @snehajitchandra2976
    @snehajitchandra2976 Před 6 lety +4

    Sir!!!! Python is really awesome language as you are teaching us.I am really get very interested from Python.thank you sir

  • @ishansaha6299
    @ishansaha6299 Před 6 lety +10

    Your videos are best continue this your channel will grow very fast

  • @rohitpagar17
    @rohitpagar17 Před 2 lety +2

    from numpy import *
    arr1 = array ([8,5,7,8,4])
    arr2 = array ([3,6,9,2,5])
    For i in range (len(arr1)):
    arr3 = arr1 + arr2
    break
    print (arr3)

  • @mayankdegada9829
    @mayankdegada9829 Před 4 lety +4

    1. From numpy import *
    Arr1 = array ([1,2,3,4,5])
    Arr1 = array ([10,9,8,7,6])
    For y in range (0,4):
    x=arr1[y] + arr2[y]
    print (x)

  • @prathapasalistener9997
    @prathapasalistener9997 Před 5 lety +2

    Naveen,i m getting more confident on python,after seeing your tutorial videos,Thanks much.

  • @rudreshwarwarkhade7238
    @rudreshwarwarkhade7238 Před 4 lety +12

    Solution 2:
    arr=[2,11,4,5,6,12,8]
    max=arr[0]
    for i in range(1,len(arr)):
    if arr[i] >max:
    max=arr[i]
    print(max)

  • @zakiasmaa6834
    @zakiasmaa6834 Před 22 dny

    I count myself lucky to learn from your tutorial
    Thanks sir,

  • @nrhchandra
    @nrhchandra Před 3 lety +3

    for assignment 2:
    arr_a = array([-77, -65,-9,-2,-5])
    max_v = arr_a[0]
    for i in arr_a:
    if max_v < i:
    max_v = i
    print(max_v)

  • @dathashiva
    @dathashiva Před 3 lety

    add 2 arrays using forloop
    import array as arr
    b = arr.array('i',[1,2,3,4])
    c = arr.array('i',[5,6,7,8])
    for i in c:
    b.append(i)
    if len(c) == i:
    break
    print(b)
    finding the max value from array
    b = np.array([1,2,3,4])
    max = np.array([0])
    for k in range(0,len(b)):
    if (b[k] > max):
    max = b[k]
    print(max)
    taken time to sort it, but worked :)

  • @anandhisiva93
    @anandhisiva93 Před 4 lety +3

    solution for 1.
    from numpy import *
    arr1 = array([2,5,1,7,3])
    arr2 = array([1,4,6,2,3])
    arr3 =zeros(5,int)
    for i in range (5):
    arr3[i] =arr1[i]+arr2[i]
    print(arr3)

  • @Chiranjeevi-xq6qy
    @Chiranjeevi-xq6qy Před rokem +1

    1)
    from array import *
    a = array('i',[5, 6, 5, 9, 1])
    b = array('i',[8, 2, 3, 4, 7])
    c = sorted(a)
    d = sorted(b)
    e = array('i',[])
    for i in range(len(a)):
    f = c[i] + d[i]
    e.append(f)
    print(c)
    print(d)
    print(e)
    2)MAX NUMBER
    from numpy import *
    a = array([51, 36, 55, 99, 61])
    b = sort(a)
    print(b[-1])

  • @jawagarrumeshsubramaniam2867

    for pro 1:
    from array import *
    a = array('i',[1,2,3])
    b = array('i',[10,20,30])
    c = array('i',[])
    for i in range(len(a)):
    c.append(a[i] + b [i])
    print(c)

    • @sanketpathak6621
      @sanketpathak6621 Před 4 lety

      Please explain I didn't understand the 1st solution.

    • @electricpajamas6736
      @electricpajamas6736 Před 4 lety

      Same kaam itna simple ho jana tha bhai tumhary code ne dimag ke dahi kar di

    • @suparnakumar2719
      @suparnakumar2719 Před 4 lety

      What he did was he created another array and then stored the sum of the other two arrays using the append function in the third one

    • @himanisoni5791
      @himanisoni5791 Před 3 lety

      I'm getting array index out of range

  • @ashutoshchauhan9069
    @ashutoshchauhan9069 Před 4 lety +1

    Assignment >>
    1)
    from numpy import *
    arr1= array([1,2,3])
    arr2=array ([4,5,6])
    for i in range(len(arr1)):
    print(arr1[i]+arr2[i])
    2) from numpy import *
    arr1=array([1,3,6,9,4])
    for i in range(len(arr1)-1):
    if arr1[i]>arr1[i+1]:
    max=arr1[i]
    else:
    max=arr[i+1]
    print(max)
    Thanks!!!!

  • @sumitchowdhury7009
    @sumitchowdhury7009 Před 4 lety +4

    solution 2:
    from array import *
    arr = array('i',[23,34,5,6])
    for i in range(3):
    if arr[i]>arr[i+1]:
    temp = arr[i]
    arr[i]=arr[i+1]
    arr[i+1]=temp
    print(arr[3])

    • @TeymurRzayev
      @TeymurRzayev Před 2 lety

      Could you please shortly explain why you're using 3 in a range? What if I would take the length of an array as an argument? Thanks a lot!

  • @OgabekToshniyozov-kl2zs
    @OgabekToshniyozov-kl2zs Před 10 měsíci +2

    #2. Write a code to find the maximum value:
    from numpy import *
    arr=([2,4,5,21])
    max =0
    for i in range(len(arr)):
    if arr[i]>max:
    max=arr[i]
    else:
    continue
    print(f"maximum value is {max}")

  • @abuthahiramanullah2311
    @abuthahiramanullah2311 Před 5 lety +8

    from numpy import *
    arr1 =array ([1,2,3,4,5])
    arr2 =array ([6,7,8,9,10])
    for i in arr1+arr2:
    print(i)

  • @kunalchatterjee5310
    @kunalchatterjee5310 Před 4 lety

    I am looking for a job. I am a mechanical guy. Trying for CAE domain, the company I went for the interview has now asked me to learn python and come.
    I am really grateful I got this channel.
    The good thing is that I am progressing.

  • @ruchikalalit1304
    @ruchikalalit1304 Před 5 lety +3

    from numpy import *
    ar1 = array([1, 2, 33, 44, 54, 16, 32])
    m=ar1[0]
    for i in ar1:
    if i>m:
    i,m=m,i
    else:
    continue
    print(m)

    • @doshomik8787
      @doshomik8787 Před 4 lety

      would you please explain the line 'm=ar1[0]'. I can't understand this line.

  • @priyeshchoukse8806
    @priyeshchoukse8806 Před 3 lety

    from numpy import *
    arr1=array([9,2,3,4])
    arr=arr1[0]
    for i in arr1:
    if(i

    • @santhoshkj3984
      @santhoshkj3984 Před 3 lety

      Code is good. It is working. But it gives minimum value. Since he asked for maximum value u need to change iarr.

  • @skjnas
    @skjnas Před 4 lety +9

    prob-2
    from array import *
    arr = array('i',[1,2,34,56,74,77,89])
    sor = sorted(arr)
    sor.reverse()
    print(sor[0])

    • @anshul1047
      @anshul1047 Před 3 lety

      but we cannot use any built in function

  • @b.sasikumar2141
    @b.sasikumar2141 Před 4 lety

    Sometimes I'm sobbing to understand ur code sir but later I understand easily then I think it is easy to me thank for ur supporting sir to ours for python learning.... 🤝🤝👍👍🙏🙏

  • @nehaaadarsh
    @nehaaadarsh Před 4 lety +50

    After watching your videos, one by one
    I feel like I know more than my teachers 😂😂😂

  • @arvindsingh7275
    @arvindsingh7275 Před 5 lety +2

    sir : ) ) you are the best tutor of python in you tube.

  • @naveenpolasu4670
    @naveenpolasu4670 Před 5 lety +6

    The way you are explaining is fantastic. Strongly believe as you will rock

  • @313chaitanya
    @313chaitanya Před 5 lety +1

    For 1st:
    from numpy import*
    a = array([10,20,30,50,20])
    b = array([12,2,0,7,5])
    for i in a,b:
    i = a+b
    print(i)
    break

  • @ganeshiitr-cse6328
    @ganeshiitr-cse6328 Před 6 lety +5

    hii just now started to learn python , i am following your python series ... the way u r representing everything (content , background text images etc , presentation , clear explanation )in this series is awesome , can u include some assignments or project in between video series .

    • @hozaifashakeel7758
      @hozaifashakeel7758 Před 4 lety

      iit walon ko youtube pe padna par raha hai????🤨🤨🤨

    • @ganeshiitr-cse6328
      @ganeshiitr-cse6328 Před 4 lety

      @@hozaifashakeel7758 you tube is a great source of information ....isme tumhe Kya dikkat he ?
      Khi na khi se , kabhi na kabhi to pdhna hi pdta he .... I read from other sources also but I found you here only :D

    • @hozaifashakeel7758
      @hozaifashakeel7758 Před 4 lety

      @@ganeshiitr-cse6328 i thought iit is the best anyone can get

  • @Antares3482
    @Antares3482 Před 10 měsíci +1

    arr1 = [1,2,3,4,5,6]
    arr2 = [7,8,9,1,2,3]
    result = []
    for i in range(len(arr1)):
    result.append((arr1[i]) + arr2[i])
    print('result', result)

  • @sathishkumars2380
    @sathishkumars2380 Před 4 lety +3

    Thank you so much Navin for this wonderful sessions.
    # Adding 5 to each element of array:
    from numpy import *
    arr = array([1,2,4,6,5])
    #
    for i in range(5):
    arr[i] = arr[i] + 5
    print(arr)
    ___________________
    # Adding two arrays using array module:
    from array import *
    arr1 = array('i',[1,2,4,6,5])
    arr2 = array('i',[2,5,6,4,8])
    #
    arr3 = array(arr1.typecode,[])
    for i in range(5):
    x = arr1[i] + arr2[i]
    arr3.append(x)
    print(arr3)
    **Please help to do the same by using "numpy" module.
    ___________________
    # Finding max value:
    from numpy import *
    #
    arr = array([70,10,3,80,8])
    #
    max = arr[0]
    #
    for i in range(1,5):
    if arr[i] > max:
    max = arr[i]
    print("Maximum value of array is:",max)
    **Please correct me if i am not efficient.

  • @mainakdebnath4962
    @mainakdebnath4962 Před 5 lety +1

    #Thank you sir
    #Ans 1:
    from numpy import *
    arr1 = ([])
    arr2 = ([])
    n = int(input("Enter the size of the arrays : "))
    print("Enter elements of the first array : ")
    for i in range(n):
    arr1.append(int(input()))
    print("Enter elements of the second array : ")
    for i in range(n):
    arr2.append(int(input()))
    arr3 = arr1.copy()
    for i in range(len(arr1)):
    arr3[i] = arr1[i] + arr2[i]
    print(arr3)
    #Ans 2:
    from array import *
    arr = array('i', [2, 1, 3, 5])
    for i in range(len(arr)-1):
    if arr[i] < arr[i+1]:
    max = arr[i+1]
    print(max)

    • @BilalAhmed-ib3yw
      @BilalAhmed-ib3yw Před 5 lety

      why there i sneed for arr33 = arr1.copy() function? Why it is not workinh without blank arr3[]

    • @trancedellic4672
      @trancedellic4672 Před 5 lety

      1st answer wron since ur arr1 and arr2 are list not numpy array. numpy array dont support append method.. only list and normal array support append

  • @devendra1006
    @devendra1006 Před 5 lety +3

    from numpy import *
    arr1 =array([1,2,3,4])
    arr2 =array([5,6,78,3])
    b = len(arr1)
    for a in range (b):
    x = arr1[a]+ arr2[a]
    print (x,' ',end='')

  • @jayakumarpurushothama6473

    Explanation is good and can understand the demo given with background explanation.... Thanks Navin ....

  • @nishanthhollar6933
    @nishanthhollar6933 Před 4 lety +8

    from numpy import *
    arr1 = array([1, 2, 3, 4, 5])
    arr2 = array([6, 7, 8, 9, 10])
    for a, b in zip(arr1, arr2):
    print(a+b)

  • @user-no3lh7ic4e
    @user-no3lh7ic4e Před 3 měsíci

    from numpy import *
    print("adding 2 arrays using for loop")
    ar = array([3,4,5,6,7])
    ar2=array([4,5,6,7,8])
    ar3=array([])
    for i in range(len(ar)):

    ar3=ar+ar2

    print(ar3)

  • @pranaygawande5658
    @pranaygawande5658 Před 5 lety +5

    from array import *
    n = int(input("Enter the length of array:"))
    a = array("i",[])
    for i in range (n):
    x = int(input("Enter the element:"))
    a.append(x)
    l = a[0]
    for i in range(n):
    if a[i] > l:
    l=a[i]
    print(l)

  • @sujendra9725
    @sujendra9725 Před rokem

    I am learning more from u than my cllg

  • @sailakshmi3792
    @sailakshmi3792 Před 3 lety +2

    from numpy import *
    from numpy import array
    arr1 = array([1,2,7,4,9])
    max=0
    for num in arr1:
    if num>max:
    max=num
    print(max)

  • @raghavsharma6150
    @raghavsharma6150 Před 3 lety +8

    from array import *
    arr = array('i',[88,2,34,56,74,77,89])
    sor = sorted(arr)
    n = len(sor)
    print(sor[n-1])

  • @hardikjambhule3952
    @hardikjambhule3952 Před 4 lety +5

    Q 2)
    from numpy import *
    arr=array([34,12,14,15,33,22])
    max=arr[0]
    for i in range(len(arr)):
    if max

  • @OasisFinder
    @OasisFinder Před 3 lety +1

    Finding max value without inbuilt function:
    arr1 = array ([9,12,5,41,8,11,31])
    z =0
    for e in arr1:
    if z

    • @arpanswain4303
      @arpanswain4303 Před 2 lety

      Most underrated comment..
      I think z=arr1[0] will be more efficient than z=0, because if you take z=0 then finding the max value in an array of negative numbers is impossible

  • @ashokreddy8273
    @ashokreddy8273 Před 2 lety +3

    FOR 2ND ASSIGNMENT QUESTION ✌️
    from numpy import *
    arr=array([11,22,33,44,55])
    max=0
    for i in arr:
    if max

  • @user-no3lh7ic4e
    @user-no3lh7ic4e Před 3 měsíci

    2)
    ar = array([3,4,5,6,8])
    x=ar[0]
    for i in range(0,len(ar)):
    if(ar[i]>x):

    x=ar[i]
    print("The largest elemt in array is",x)

  • @mamodul-kabir
    @mamodul-kabir Před 5 lety +22

    Solution for number 2:
    from numpy import *
    ar =array([71,18,5,27,9])
    ar.sort()
    print(ar[len(ar)-1]," is the maximum value")

    • @Sandythecoder1010
      @Sandythecoder1010 Před 4 lety +5

      what about not using built in function?

    • @samchaudhry908
      @samchaudhry908 Před 4 lety +7

      @@Sandythecoder1010 Check my solution
      from numpy import *
      print("******Copying an Array**********")
      arr1 = array([100,15,19,17,225])
      max = 0
      for i in range(len(arr1)):
      if arr1[i] > max:
      max = arr1[i]
      else:
      pass
      print(max)

    • @Sandythecoder1010
      @Sandythecoder1010 Před 4 lety +1

      @@samchaudhry908 Right but you can still improve your code.

    • @moizghauri5578
      @moizghauri5578 Před 4 lety +2

      @@Sandythecoder1010
      arr = array('i', [1, 2, 8, 5, 6])
      maxi = 0
      for i in range(len(arr)):
      if (arr[i] > maxi):
      maxi = arr[i]
      print(maxi)

    • @dilipn367
      @dilipn367 Před 4 lety +1

      @@moizghauri5578 all the items in arr are greater than 0

  • @destroyer3706
    @destroyer3706 Před 6 lety +1

    very good video, teaching style is v good and understandable, I am new to programming and learning quite well, Thankyou

  • @adarshsharma1786
    @adarshsharma1786 Před 5 lety +8

    Solution For 2!!!!!!!
    from numpy import *
    a= array([44,211,12,110,1144])
    mx=0
    for i in range(4):
    if a[i]>a[i+1] and a[i]>mx:
    mx=a[i]
    elif a[i+1]>mx:
    mx=a[i+1]
    print('Maximum value is',mx)

    • @dhairyamehta8354
      @dhairyamehta8354 Před 4 lety +2

      i have a better code:
      from array import*
      arr=array('i',[1,2,3,5,4])
      maximum= arr[0]
      for i in range(1,5):
      if arr[i]>maximum:
      maximum=(arr[i])
      print(maximum)

  • @vernittyagi5523
    @vernittyagi5523 Před 5 lety +6

    solution for problem 2:--->>
    from numpy import *
    arr = array([1,2,3,4,5])
    max = arr[0]
    for i in range(5):
    if arr[i] > max:
    max = arr[i]
    print("max is: " , max)

  • @Arvindkumar-kd7yi
    @Arvindkumar-kd7yi Před 4 lety +2

    Q:write a code to find the maximum value from an array without using built in function.
    Ans: from numpy import *
    arr=array([])
    n=int(input('enter the size of array:'))
    for i in range(n):
    x=int(input('enter the value:'))
    arr=append(arr,x)
    print(arr)
    for e in arr:
    for z in range(n):
    if e>=arr[z]:
    pass
    else:
    break
    else:
    print(e,'is th greatest number')

  • @SIDDARTHGUPTACDCS
    @SIDDARTHGUPTACDCS Před 4 lety +6

    from numpy import *
    a=array([41,22,39,57,12])
    p=a[0]
    for e in a:
    if e>=p:
    p=e
    print(p)

  • @Rajadahana
    @Rajadahana Před 2 lety

    I would like to shout this at the top of my lungs.
    YES, I AM ENJOYING NAVIN'S LESSONS!!!

  • @vamsimanchikanti9399
    @vamsimanchikanti9399 Před 6 lety +5

    code:
    from numpy import *
    arr = array([1,2,3,4,5])
    print(arr)
    for i in range(len(arr)):
    arr[i] = arr[i]+5
    print("the new array is ", arr)

  • @sauravkarmakar3704
    @sauravkarmakar3704 Před 4 lety +1

    from numpy import *
    arr= array([3,53,5,4,1,52,7,23,1,3])
    min = arr[0]
    for i in range(0,len(arr)-1):
    if arr[i+1] < min :
    min = arr[i+1]
    print(min)

    • @sauravkarmakar3704
      @sauravkarmakar3704 Před 3 lety

      arr = array([1,2,3,43,4,5])
      max = arr[0]
      for i in range(len(arr)-1):
      if arr[i+1]> max:
      max = arr[i+1]
      print(max)

  • @mohamedfaalil
    @mohamedfaalil Před 5 lety +6

    from array import *
    arr1 = array('i',[1, 2, 3, 9])
    arr2 = array('i',[1, 2, 3, 4])
    arr3 = array('i',[])
    l_arr1 = len(arr1)
    l_arr2 = len(arr2)
    if l_arr1 == l_arr2 :
    for i in range(l_arr1):
    arr3.append(arr1[i]+arr2[i])
    else:
    print("Both array should be same length !")
    print("Added new values :\t")
    for j in arr3 :
    print(j,"\t",end="")

  • @aakashverma8602
    @aakashverma8602 Před 5 lety

    arr = array([12,2,43,56,78])
    p = 0
    for i in range(len(arr)):
    if p

    • @ARJUNKUMAR-cr1gq
      @ARJUNKUMAR-cr1gq Před 5 lety

      If all are negative in array, then it will print maximum value 0, while It is not part of array

  • @BoomcoreIsLive
    @BoomcoreIsLive Před 5 lety +5

    #Addition
    from numpy import *
    arr = array([10,200,30])
    arr1 = array([40,300,20])
    arr2 = zeros (3,int)
    for x in range(len(arr)):
    arr2[x] = arr[x]+arr1[x]
    print(arr2)

  • @sainikhila4027
    @sainikhila4027 Před 4 lety +5

    #2
    from array import *
    a = ([1,3,5,2])
    a.sort()
    print(a[-1])
    print(a)

  • @Rohitkumar-tx6jl
    @Rohitkumar-tx6jl Před 3 lety

    Wow guru jee y are one of the best
    You have deep knowledge in this field I hope this

  • @divyanshusingh6105
    @divyanshusingh6105 Před 4 lety +4

    Quiz: 1-
    from numpy import *
    arr1 = array([1,2,3,4,5])
    arr2 = array([5,6,7,8,9])
    arr3 = array([])
    for i in range(5):
    arr1[i]= arr1[i]+arr2[i]
    arr3=arr1
    print(arr3)

    • @harshitagrwal9975
      @harshitagrwal9975 Před 4 lety

      Bro where you have wriiten Arr1[i]
      Can't we write arr3[I] there
      Mera mtlb direct arr3[I] q ni likhe ho...baad me Arr1 ko arr3 me copy ni Krna pdta...

  • @shwetabhpandey2207
    @shwetabhpandey2207 Před 5 lety +3

    from array import *
    a=array('i',[1,2,3,4,5])
    b=array('i',[5,4,3,2,1])
    c=array('i',[])
    for i in range(0,5):
    c.append(a[i]+b[i])
    print(c)

  • @ikuyinminusolomon3934
    @ikuyinminusolomon3934 Před 3 lety +2

    arr=array([1,2,3,4,5])
    for i in range(1):
    print(arr+5)

  • @FactsDiscoveryyoutube
    @FactsDiscoveryyoutube Před 4 lety +3

    from array import *
    arr =array('i',[1,2,5,3,7])
    maxValue =0
    for i in range(len(arr)):
    if arr[i]>maxValue:
    maxValue =arr[i]
    print(maxValue)
    output:7

  • @hariteshkumar281
    @hariteshkumar281 Před 3 lety +1

    from numpy import *
    arr = array([5,6,7,8,2,1],int)
    for arr in arr:
    print(arr+5)

  • @namratasurve6708
    @namratasurve6708 Před 5 lety +3

    1.code 1
    from numpy import *
    arr1 = array([3,78,9,56])
    arr2 = array([35,8,79,36])
    arr3 = ones(4,int)
    k=0
    for k in range(4):

    for a in arr1:
    for b in arr2:
    arr3[k]=arr1[k]+arr2[k]
    print(arr3)
    2.code 2
    from numpy import *
    arr = array([3,90,9,56])
    max=arr[0]
    for i in range(4):
    if max

  • @MuhammadAdnan-zy1th
    @MuhammadAdnan-zy1th Před 3 lety +1

    Wow sir I love your teaching method you explain everything clearly and I like it. I've learned many things from you

  • @mohamedfaalil
    @mohamedfaalil Před 5 lety

    from numpy import *
    val = array([45,25,16,10,2,798,-78,-1])
    min = max = val[0]
    for i in val:
    if i > max:
    max = i
    elif i < min:
    min = i
    print("Maximum value of the array element is :\t",max)
    print("Minimum value of the array element is :\t",min)

  • @umasanodiya6917
    @umasanodiya6917 Před 5 lety +3

    arr= array([1,10,5,6])
    Max=0
    for i in arr:
    if i>max:
    Max=i
    print(max)

  • @mbisur1
    @mbisur1 Před 4 lety +1

    1st Solution:
    from numpy import *
    arr1 = array([5,10,7,8,4])
    arr2 = array([3,5,9,14,17])
    for i in range(len(arr1)):
    arr3 = arr1 + arr2
    print(arr3)

  • @urvi.sharma
    @urvi.sharma Před 3 lety +1

    //Adding 5 to each element of an array//
    from numpy import *
    arr = array([2,4,3,1,5])
    for i in range(len(arr)):
    arr[i] += 5
    print(arr)

  • @suryakantbjadhav
    @suryakantbjadhav Před 2 lety +1

    Adding 5 to each number
    from numpy import *
    arr = array([2, 3,4,5])
    print(arr[0:]+5)

  • @85-sowndaryam16
    @85-sowndaryam16 Před 3 lety

    Thank u so much sir the way u teach is really awesome....I understand much better here than my clg

  • @ashokreddy8273
    @ashokreddy8273 Před 2 lety +1

    2nd assignment question
    from numpy import *
    arr1=array([12,23,34,45,56,67])
    arr2=array([21,32,43,54,65,76])
    arr3=array ((n for n in arr1)+(k for k in arr2))
    print(c)

  • @abhaychoudhary9149
    @abhaychoudhary9149 Před rokem

    sir good morning
    i am enjoying this series a lot love u sir...

  • @bhavin7137
    @bhavin7137 Před 7 měsíci

    1.
    # import the array module
    import array as arr
    # create two arrays with some values
    arr1 = arr.array('i', [2, 4, 6, 8, 10])
    arr2 = arr.array('i', [1, 3, 5, 7, 9])
    # create an empty array to store the sum
    arr_sum = arr.array('i')
    # get the length of the arrays
    n = len(arr1)
    # loop through the arrays
    for i in range(n):
    # add the elements at the same index
    s = arr1[i] + arr2[i]
    # append the sum to the new array
    arr_sum.append(s)
    2.
    import array as arr
    # create an array with some values
    a = arr.array('i', [10, 20, 30, 40, 50])
    # initialize the max value to the first element
    max_value = a[0]
    # loop through the array
    for i in range(1, len(a)):
    # compare each element with the current max value
    if a[i] > max_value:
    # update the max value if a larger element is found
    max_value = a[i]
    # print the max value
    print(max_value) # Output: 50

  • @GamingIn30s
    @GamingIn30s Před 4 lety +2

    sol 2
    finding maximum value
    arr = array('i',[1,2,30,2,5,4])
    x=0
    for i in arr:
    for e in arr:
    if e>x:
    x=e
    print(x)

    • @krishnavs3805
      @krishnavs3805 Před 4 lety

      Good, but only works for positive numbers

  • @meetpatel6972
    @meetpatel6972 Před 3 lety

    2:
    import numpy as np
    arr = np.array([1,6,1000,2,300])
    a = arr[0]
    for i in range(len(arr)):
    if a

  • @nassifchamoun3054
    @nassifchamoun3054 Před 3 lety

    for question number 2:
    from numpy import *
    arr = array ([5,7,2,8,1])
    arr1= append(arr.copy(),0)
    for i in range(0,len(arr)):
    for j in range(i+1,len(arr1)):
    if arr[i] > arr1[j]:
    a= arr[i]
    else:
    b=arr1[j]
    if a>b:
    print(a, 'is the greatest value')
    else:
    print(b, 'is the greatest value')

  • @1gamerCasual10
    @1gamerCasual10 Před 8 měsíci

    2)
    from numpy import *
    arr1 = array([175, 973, 181, 873, 1056, 157, 354, 279, 710, 199])
    numMax = 0
    for i in arr1:
    if i > numMax:
    numMax = i
    print(numMax)

  • @sanjaysoni3550
    @sanjaysoni3550 Před 6 lety +2

    Hi sir.. loved all ur videos.. keep posting. Previously learned java from u then SQL and now python.. thanks :)

  • @abhishekjadhav9289
    @abhishekjadhav9289 Před měsícem

    I did not do the manual way of loop instead i used the dynamic way you have shown in the earlier videos
    from array import *
    arr = array('i',[1,2,3,4,5])
    copyarr = array(arr.typecode, (a+5 for a in arr))
    print(copyarr)

  • @safwansahil1127
    @safwansahil1127 Před rokem

    from array import *
    n=int(input('Enter Length Of Array'))
    arr=array('i',[])
    for i in range(n):
    x=int(input('Enter Your Value'))
    arr.append(x)
    print(arr)
    print(max(arr))

  • @alameinmohammed4021
    @alameinmohammed4021 Před 4 lety

    from numpy import *
    ar = array([6,8,40,6,45])
    for i in range(len(ar)):
    for a in range(i+1,5):
    if ar[i]< ar[a]:
    break
    else:
    y = ar[i]
    break
    print(y)

  • @luvgupta5500
    @luvgupta5500 Před 4 lety

    sum of two arrays having diff no of elements:
    from numpy import *
    a1=array([2,5,8,6,4,9,7])
    a2=array([6,8,3,7,2,5])
    l1=len(a1)
    l2=len(a2)
    if(l1max):
    max=a1[i]
    print(max)

  • @saikiran4916
    @saikiran4916 Před 5 lety

    1st answer:
    from numpy import *
    arr = array([1,2,3,4,])
    size = len(arr)
    max_val = arr[0]
    for i in range(1,size):
    if max_val < arr[i] :
    max_val = arr[i]
    print(max_val)
    thank you :)