Hey Programming Portal, nice to meet you! I just found your channel, love what you're doing! I like how clear and detailed your explanations are as well as the depth of knowledge you have surrounding the topic! Since I run a tech education channel as well, I love to see fellow Content Creators sharing, educating, and inspiring a large global audience. I wish you the best of luck on your TH-cam Journey, can't wait to see you succeed! Your content really stands out and you've put so much thought into your videos! Cheers, happy holidays, and keep up the great work ;)
data = [55,1,45,68,159,75,5,14] def find_max(data, i, value): if i >= len(data) - 1: return value if isinstance(data[i], int): if data[i] > value: value = data[i] return find_max(data, i+1, value) print(find_max(data, 0, 0))
Hi, this is because we explicitly explained that the second largest number should not be the same as the first largest in the video. But if you want to implement with such scenarios, change the below line, which enforces the above validation. Change this elif list[i] > second_max and first_max !=list[i]: To elif list[i] > second_max: Hope this helps.
def find_max_min_number(array): largest_num=array[0] second_largest_num=0 for i in array: if i > largest_num: largest_num=i print("Largest number is:",largest_num) for i in array: if i > second_largest_num and i !=largest_num: second_largest_num=i print("Second Largest Number:=",second_largest_num) array_range=int(input("Enter Array Range:")) loop_counter=0 nums=[] for i in range(array_range): loop_counter+=1 print(loop_counter,end=" ") element=int(input("Enter Array Element:")) nums.append(element) array=[] for i in nums: if i not in array: array.append(i) print('Remove All Dublicates:',array) find_max_min_number(array)
code to find second smallest number in list l = [1,2,3,4,5,0] first = min(l[0],l[1]) sec = max(l[0],l[1]) for i in range(2,len(l)): if l[i] < first: sec = first first = l[i] elif l[i] < sec and first != l[i]: sec = l[i] print(sec)
You can change for loop to while loop similar to below code. Ref code is just snippet, please write full code. Hope this helps. for i in range(2, len(list1)): To i=2 While i
Hey Programming Portal, nice to meet you! I just found your channel, love what you're doing!
I like how clear and detailed your explanations are as well as the depth of knowledge you have surrounding the topic! Since I run a tech education channel as well, I love to see fellow Content Creators sharing, educating, and inspiring a large global audience. I wish you the best of luck on your TH-cam Journey, can't wait to see you succeed! Your content really stands out and you've put so much thought into your videos!
Cheers, happy holidays, and keep up the great work ;)
data = [55,1,45,68,159,75,5,14]
def find_max(data, i, value):
if i >= len(data) - 1:
return value
if isinstance(data[i], int):
if data[i] > value:
value = data[i]
return find_max(data, i+1, value)
print(find_max(data, 0, 0))
Super.. Also provide second smallest in a list program
Please write code for second smallest number, if i already find first smallest number
Could you please this code in while loop
not working for this kind of input for list1= 6,6,-6,6 or list2=6,6,6,6,6,6,5
ya also 57,57,-57,57
Hi, this is because we explicitly explained that the second largest number should not be the same as the first largest in the video. But if you want to implement with such scenarios, change the below line, which enforces the above validation.
Change this
elif list[i] > second_max and first_max !=list[i]:
To
elif list[i] > second_max:
Hope this helps.
def find_max_min_number(array):
largest_num=array[0]
second_largest_num=0
for i in array:
if i > largest_num:
largest_num=i
print("Largest number is:",largest_num)
for i in array:
if i > second_largest_num and i !=largest_num:
second_largest_num=i
print("Second Largest Number:=",second_largest_num)
array_range=int(input("Enter Array Range:"))
loop_counter=0
nums=[]
for i in range(array_range):
loop_counter+=1
print(loop_counter,end=" ")
element=int(input("Enter Array Element:"))
nums.append(element)
array=[]
for i in nums:
if i not in array:
array.append(i)
print('Remove All Dublicates:',array)
find_max_min_number(array)
code to find second smallest number in list
l = [1,2,3,4,5,0]
first = min(l[0],l[1])
sec = max(l[0],l[1])
for i in range(2,len(l)):
if l[i] < first:
sec = first
first = l[i]
elif l[i] < sec and first != l[i]:
sec = l[i]
print(sec)
bohot ganda hai
Could you please this code in while loop
You can change for loop to while loop similar to below code.
Ref code is just snippet, please write full code. Hope this helps.
for i in range(2, len(list1)):
To
i=2
While i