Комментарии:
#1
arr = ([4, 5, 6, 7, 10])
m = 0
for i in range(len(arr)):
if arr[i] > m:
m = arr[i]
else:
continue
print(m)
#2
from array import *
ar = array('i', [2, 4, 5, 7])
ar1 = array('i', [4, 6, 7, 9])
e = 0
for i in range(len(ar)):
if e <= len(ar1):
ar[i] = ar[i] + ar1[e]
e+=1
print(ar)
Hi Folks, anyone who observed my comment
Tell me how to sort an array in descending order, I am asking about an array not lists.
Hope atleast i got positive response from one of u, Thanks!!
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)
#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}")
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.
ОтветитьBest ever python playlist sir🔥🔥🔥🔥🔥🔥🔥
Ответить#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))
in this video when we added two array its not working even i m doing same its returning all 8 value in one array
ОтветитьThank you so much sir.
Ответить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])
im getting the same address even after using the view or copy function did i made a mistake?
ОтветитьWhy bro in output commars are not showing
Ответитьassignment 1:
arr1 = array([5,1,3,7])
arr2 = array([7,3,5,1])
arr3 = []
for i in range(4):
newval = arr1[i] + arr2[i]
arr3.append(newval)
print(arr3)
assignment 2:
arr1 = array([3,7,1,9,6])
max = arr1[0]
for i in range(len(arr1)):
if arr1[i]>max:
max = arr1[i]
print(max)
I am learning more from u than my cllg
Ответить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))
from numpy import *
arr= array([34,56,5,78,67])
m=0
for val in arr:
for i in range(len(arr)):
if val>=arr[i]:
m= val
else:
val= arr[i]
print(m)
without using inbuild function max value
different python lib seekhni hai, uske liye kya kare?
ОтветитьThis is my solution
from numpy import *
1. write a code to add two arras using for loop
arr1 = array([85,8,76,4,10])
arr2 =array([6,5,9,1,3])
for i in range(len(arr1)):
k = arr1[i]+arr2[i]
print(k)
2. write a code to find the maximum value from an array without using a built in function
arr1 = array([85,8,76,4,10])
hN = 0
for i in range(len(arr1)):
if arr1[i] >= hN:
hN=arr1[i]
print(hN)
Error: Array() argument 1 must be a unicode character, not list when we add +5
ОтветитьCan we have lecture of Pandas Library as well?
Ответить1.
from numpy import *
arr1 = array([1,2,3,4])
arr2 = array([5,6,7,8])
arr = zeros(4,int)
for i in range(len(arr)):
arr[i]= arr1[i]+arr2[i]
print(arr)
.......................................................
2.
from numpy import *
arr = array([1,2,3,4])
max = arr[0]
for i in arr:
if max < i:
max = i
print (max)
was not getting why do we use those function here not able to understand that
ОтветитьSo, i was trying to add two arrays via for loop, although i am able to do it with array and append in array, there is no append option in numpy. is it not possible to do so?
Ответитьhow do i import the numpy funtion on my python ide. i dont have access to numpy
Ответитьsir shall we use list instead of this will you plz reply me sir and tha another doubt for me is numpy is very important if u have time reply me 🙃
Ответитьsir good morning
i am enjoying this series a lot love u sir...
my is comming 7 in both the arrays
Ответитьthanks for the video
Ответить1)
from numpy import *
arr1 = array([1,2,3,4,5])
arr2 = array([5,8,4,9,5])
for i in range(5):
arr3=arr1 +arr2
print (arr3)
2)
from numpy import *
arr = array([11,2,35,14,56])
maxarr=arr[0]
for i in range(len(arr)):
if arr[i]>maxarr:
maxarr=arr[i]
print(maxarr)
2.from numpy import *
lays=[10,12,3,4,5]
for i in range (int(len(lays))):
if lays[i]>lays[0]:
print(lays[i])
1. from array import *
lays=array('l',[1,2,3,4,5])
layys=array('l',[6,7,8,9,10])
for i in range (int(len(lays))):
lays.append(lays[0]+layys[i])
del (lays[0])
print(lays)
Assignment Answers:
from numpy import *
t = int()
arr1 = array([4, 5, 6, 7])
arr2 = array([8, 9, 10, 11])
arr3 = array([])
for i in range(len(arr1)):
t = arr1[i] + arr2[i]
arr3 = append(arr3, t)
______________________________
t = int()
for i in arr1:
if i > t:
t = i
print(t)
Q. 2.
arr=[]
rng=int(input("enter the range of the array : "))
for i in range(0,rng):
l=int(input("enter the value now : "))
arr.append(l)
print(arr)
t_max=arr[0]
for i in range(len(arr)):
if arr[i]>t_max :
t_max=arr[i]
print(t_max)
from numpy import *
arr1 = array([1,5,22,45,18,55])
arr2 = array([5,4,6,8,9,5])
for i in add(arr1,arr2):
print(i)
output :
6
9
28
53
27
60
Where i can get practice problems to solve on arrays??
ОтветитьAdding 5 to each element:
from numpy import *
arr = array([1,2,3,4,5])
print(arr)
for i in range(len(arr)):
arr[i] = arr[i]+5
print(arr)
what is the difference between aliasing and shallow copy?
ОтветитьIt was awesome... Thank you
Ответитьfrom numpy import *
arr = array([5, 6, 9, 8, 7])
arr2= array([10, 11, 14, 13, 12])
arr3=[]
for e in range(5):
k=arr[e]+arr2[e]
arr3.append(k)
print(arr3)
from numpy import *
arr1 = array([1, 12, 3, 5, 19, 11])
max = arr1[0]
for i in range (6):
if max < arr1[i]:
max = arr1[i]
continue
else:
continue
print(max)
from array import *
arr1 = array('i',[])
arr2 = array('i',[])
num = int(input("enter the number of elements : "))
for i in range(num):
x = int(input("enter the value : "))
arr1.append(x)
print("first array is :",end = " ")
print(arr1)
for j in range(num):
z = int(input("enter the value : "))
arr2.append(z)
print("second array is :",end = " ")
print(arr2)
for i in range(num):
sum = arr1[i]+arr2[i]
print(sum,end ="")
arr = np.array([5,-9,15,0,13,18,1])
max = 0
for i in arr:
print('maxx i val : ',i,'MAX',max)
if i >= max:
max = i
print(max, "is maximum")
Thank you very much. You are a genius.
Ответитьwith arr1.view() we are supposed to have different addresses. then why after changing arr1[1] to 7 both arrays printed same address, even using views.
Ответитьsir, I have a small doubt what's the use of shallow copy I mean if both the array will have the same id also it will act as a shallow copy, and moreover, shallow copy copies the whole array so it has O(n) time complexity?
Ответитьfrom numpy import*
arr = array([1,2,3,4,5])
for elements in arr:
arr+=5
print(arr)
break
after following this you can get your output
Navin Sir Am i right?