Python Unique Number | for loop in python | python programming| python shorts #shorts #ytshorts

preview_player
Показать описание
WAP to get second highest value
from the list.
data = [1,2,8,3,12]

Code:
ldata = [1,2,8,3,12]

print("second highest value: ",data[-2])

while count length:
print(n1)
nth = n1+n2
n1 = n2
n2 = nth
count += 1

output:
second highest value: 8

new video for python programming
python code for problem solving approach.
- python for beginners
- learn python in simple way.
- first clear basic concepts.
- solve more problems and consistent practice.

for loop in Python Program
python programming for beginners
python programming examples
python for loop
learn python

#shorts #ytshorts #pythonprogram #tutorial #education #learning #python programmer #python

Рекомендации по теме
Комментарии
Автор

If you're dealing with bigger data sets, it will be faster to do a sort first, and just skip if you saw just the last number already.

Checking every member every time is O(N^2) or O(n!) (I'm not actually sure and I'm too lazy to work it out right now) while sorting and stepping is O(nlogn)

AvenDonn