STACK IMPLEMENTATION | Push, Pop, Display | Class 12 Python | Computer Science for Board

Поделиться
HTML-код
  • Опубликовано: 2 янв 2025

Комментарии • 272

  • @grin2groin._.624
    @grin2groin._.624 Год назад +36

    Namaste Harsh sir.
    Mein abhi abhi scl se half yearly exams deke aa rha hu.
    Aapke python ke videos mein last 3 days se follow kar rha hu aur sir aaj sahi mein exam hall mein paper deke khushi hua.
    Thank you sir.
    Aapke lectures bahut helpful hai.
    Kam time mein best way hai ye series python sikhne ke liye.

  • @TofuMilkbread
    @TofuMilkbread 2 года назад +157

    CODE:
    s=[]
    top=None
    def isEmpty(stk):
    if stk==[]:
    return True
    else:
    return False
    def push(stk,item):
    s.append(item)
    top=len(stk)-1
    def spop(stk):
    if(isEmpty(stk)):
    return('UnderFlow!')
    else:
    i = stk.pop()
    if(len(stk) ==0):
    top=None
    else:
    top=top-1
    return i
    def peek(stk):
    if isEmpty(stk):
    return('underflow')
    else:
    top=len(stk)-1
    return(stk[top])
    def display(stk):
    if(isEmpty(stk)):
    print('Stack is empty!')
    else:
    top=len(stk)-1
    print(stk[top],'

  • @devyanshgupta2901
    @devyanshgupta2901 9 месяцев назад +48

    best of luck everyone jiska bhi subah exam hai

  • @epiccube8594
    @epiccube8594 9 месяцев назад +8

    All the best to all for today's exam

  • @gamerzzhub5964
    @gamerzzhub5964 9 месяцев назад +98

    kis kis ka exam kl hai???

    • @24rage
      @24rage 9 месяцев назад +6

      Bhai dimg sahi hai ?sabka kal he hoga

    • @atozgaming7536
      @atozgaming7536 9 месяцев назад +4

      lol mera bhi hai kl,
      good luck aapko bhi 👍

    • @PeachePeache-o7w
      @PeachePeache-o7w 9 месяцев назад +1

      Samjh ni aara kuch🤧🤧

    • @sim4373
      @sim4373 9 месяцев назад

      ​@@24ragerude

    • @jitinkumar124
      @jitinkumar124 9 месяцев назад +1

      Aaj h😅

  • @Ayushpatell88
    @Ayushpatell88 24 дня назад +14

    All the best for your 29 March 2025 exam❤

  • @nishantpanda848
    @nishantpanda848 2 года назад +84

    11:25 the most epic part🤣🤣🤣

  • @nathenmathew5667
    @nathenmathew5667 3 года назад +60

    pls post notes for this video notes are the best parts of the series

    • @ignaitog
      @ignaitog 2 года назад +5

      Abbe Yeh code h Iske koi notes thodi hain lmao

  • @funwithkrish009
    @funwithkrish009 9 месяцев назад +5

    All the best for you 2 april 2024 Exam ❤

  • @divyanshujod
    @divyanshujod 3 года назад +19

    Best in the world "Aman dhattarwal" zabardast.

  • @puneetpradhan7657
    @puneetpradhan7657 3 года назад +7

    Thanks a lot :)))
    Love to the apni kaksha team

  • @manasgupta7724
    @manasgupta7724 9 месяцев назад +3

    5:15 sir but agar hame shrif peek karna hai to ham direct -1 index bhi to print kara sakate hai wo bhi to top he hai

    • @vivaanreddy8771
      @vivaanreddy8771 9 месяцев назад

      stack = []
      def push(stk, item):
      stk.append(item)
      def pop(stk):
      if not stk:
      return 'Underflow!'
      return stk.pop()
      def peek(stk):
      if not stk:
      return 'Underflow!'
      return stk[-1]
      def display(stk):
      if not stk:
      print('Stack is empty!')
      else:
      print('Top of the stack: ', stk[-1])
      print('Stack elements:')
      for item in reversed(stk):
      print(item)
      while True:
      choice = input('''STACK IMPLEMENTATION
      1. PUSH
      2. POP
      3. PEEK
      4. DISPLAY
      5. EXIT
      Enter your choice (1-5): ''')

      if choice == '1':
      item = int(input("Enter the item you want to push: "))
      push(stack, item)
      print(item,' added successfully')

      elif choice == '2':
      item = pop(stack)
      if item == 'Underflow!':
      print('Stack is empty')
      else:
      print(item,' popped from the stack')

      elif choice == '3':
      item = peek(stack)
      if item == 'Underflow!':
      print('Stack is empty')
      else:
      print('%d is at the top of the stack' % item)

      elif choice == '4':
      display(stack)
      elif choice == '5':
      break
      else:
      print('Invalid input')

      print('

      ')

  • @college1494
    @college1494 3 года назад +12

    NOTES UPLOAD KAR DO BHAIYA!!!!!
    PRACTICALS AND PRE BOARDS H

  • @Kidzone1289
    @Kidzone1289 3 года назад +2

    Aman bhaiya zindabad....🙏🙏🙏

  • @gauravkaushik9384
    @gauravkaushik9384 2 года назад +15

    def Push(stk,item):
    stk.append(item)
    print("Item is added successfully to the stack")
    def Pop(stk):
    if stk==[]:
    print("Stack is already Empty")
    else:
    stk.pop()
    def Display(stk):
    a=stk[::-1]
    print(a)
    stk=[]
    while True:

    print("1.Push
    2.Pop
    3.Display")
    ch=int(input("Enter Your Choice:::"))
    if ch==1:
    no.=int(input("Enter no. to be added:::"))
    Push(stk,no.)
    if ch==2:
    Pop(stk)
    if ch==3:
    Display(stk)

    • @Rbrnrntbetntybet
      @Rbrnrntbetntybet 2 года назад +2

      Thodan jyada he 'if' use kar diya . All the best for cs exam.

    • @MadMax-fs3cy
      @MadMax-fs3cy 2 года назад

      @@Rbrnrntbetntybet elif hoga right?

    • @mrsprite399
      @mrsprite399 2 года назад

      @@MadMax-fs3cy
      Haa
      If ch==1 ke baad elif= 2, 3,4...etc hoga

    • @GamingBeastR4W
      @GamingBeastR4W 2 года назад

      @@MadMax-fs3cy else bhi hoga last me
      if -elif - else

    • @Shubham-oo8vv
      @Shubham-oo8vv 2 года назад

      Item is not defined

  • @eugenemartin7475
    @eugenemartin7475 2 года назад +30

    itna bhagaate kyu ho yaar saare videos me

    • @yashsharma3280
      @yashsharma3280 2 года назад +1

      ya

    • @subasit122
      @subasit122 9 месяцев назад +1

      Nahi bhagane par phir tum log 2x pe dekhto ho isiliye

    • @amanguptan
      @amanguptan 3 месяца назад

      ​@@subasit122Tu dekhta hoga 2x pe hmlog nhi jo chiz pehle padh liye hai usko 2x me dekha jata hai per ye aaj padh reha hai or ye channel khud 2x me video bhaga reha hai

    • @chamanpreetverma1869
      @chamanpreetverma1869 26 дней назад

      4 saal purani hai video 😑​@@amanguptan

  • @BilashiniOram-fo1hm
    @BilashiniOram-fo1hm 9 месяцев назад +3

    12:30 most epic

  • @horde479
    @horde479 2 года назад +12

    i tried writing the code :D
    s = []
    top = None
    def isEmpty(stk):
    if stk==[]:
    return True
    else:
    return False
    def push(stk,item):
    stk.append(item)

    def pop(stk):
    if(isEmpty(stk)):
    return('UnderFlow')
    else:
    i = stk.pop()
    return i
    def peek(stk):
    if isEmpty(stk):
    return('underflow')
    else:
    return(stk[len(stk)-1])
    def display(stk):
    if(isEmpty(stk)):
    print('Stack is empty!')
    else:
    top=len(stk)-1
    print(stk[top],'

  • @brrrrrrrrrr9313
    @brrrrrrrrrr9313 2 года назад +2

    are ch==5 k niche break dene se kay kisika error dikah raha h?? error- break outside the loop

  • @aditya__exe
    @aditya__exe 3 года назад +11

    11:23 🤣🤣🤣🤣

  • @atozintelligence4792
    @atozintelligence4792 3 года назад +6

    Thank you so much Aman Bhaiya and Team 🙏🏻

  • @viee488
    @viee488 Год назад +4

    THE CORRECT CODE
    s=[]
    top=None
    def isEmpty(stk):
    if stk==[]:
    return True
    else:
    return False
    def push(stk,item):
    s.append(item)
    top=len(stk)-1
    def spop(stk):
    if(isEmpty(stk)):
    return('underflow')
    else:
    i = stk.pop()
    return i
    if(len(stk) ==0):
    top=None
    else:
    top=top-1

    def peek(stk):
    if isEmpty(stk):
    return('underflow')
    else:
    top=len(stk)-1
    return(stk[top])
    def display(stk):
    if(isEmpty(stk)):
    print('Stack is empty!')
    else:
    top=len(stk)-1
    print(stk[top],'

    • @adityabhandari6145
      @adityabhandari6145 Год назад

      What does %d and %item mean?

    • @viee488
      @viee488 Год назад

      @@adityabhandari6145 check out 8:45 you will get it

    • @obssgurl-yk5qg
      @obssgurl-yk5qg Год назад

      @@viee488 yes but what does it mean?

  • @ArryanhMesson
    @ArryanhMesson Год назад +5

    Why we are writing top = len(stk)-1
    why not top = len(stk) only

    • @mihirsamanyut219
      @mihirsamanyut219 9 месяцев назад +5

      basically top gives us the index of the most recent element in stack and the indexing in list starts from 0 onwards, so top= len(stk)-1. Eg: L=[a,b,c,d] the len(L)=4 but index of d is 3. Hope this helps!

  • @manaspandey7243
    @manaspandey7243 3 года назад +31

    Hatts of to harsh bhaiya,aman bhaiya and all bhaiyas and Didi's😊😊😊 for making a pure and awesome content. You would always be remembered.
    Respect man!!!! Respect$$$😌

  • @riachuphal3233
    @riachuphal3233 3 года назад +15

    Me : writing andhe 1.... 5dalna tha in my pre board if I've to write menu driven program for stack
    My marks : Rip💔🙂

    • @DevSharma-ez1gx
      @DevSharma-ez1gx 3 года назад +1

      Andhe galat ch padh liya term 1 me nhi tha 😂

    • @thattechieguy
      @thattechieguy 2 года назад

      @@parveenparveen4565 most probably case based question or a sample code edit problems

  • @adityaa.28
    @adityaa.28 3 года назад +1

    Thankyou bhaiya!!☺️☺️☺️

  • @meghasaxena8264
    @meghasaxena8264 3 года назад +4

    how can this code be used for string value

  • @void8668
    @void8668 4 месяца назад +1

    Can anyone explain to me what this %d and %item is for?

  • @yadav_ji_788_
    @yadav_ji_788_ 9 месяцев назад +1

    Thnx sir😊😊

  • @callisto1836
    @callisto1836 3 года назад +17

    thank you for such great lecture harsh sir you teach really well

  • @devikaharlalka5468
    @devikaharlalka5468 3 года назад +13

    Sir pls phy ka second books ka notes dedijiye mra preboards hai

  • @HarshKumar-sh3hm
    @HarshKumar-sh3hm 3 года назад +2

    Description mai code Kaha hain

  • @MamtaSharma-ji8qb
    @MamtaSharma-ji8qb 3 года назад +2

    bhaiya huge huge huge request to u pls upload aldehyde ,ketones notes 🙏🙏🙏🙏🙏🙏🙏🙏

  • @debanjanmajumdar5383
    @debanjanmajumdar5383 2 года назад +4

    Eat well, Sleep well and study well...🙂

  • @kitoo2624
    @kitoo2624 3 года назад +2

    what is the use of %d here?

    • @thattechieguy
      @thattechieguy 2 года назад +2

      just a future reference operator ..

  • @inshazaidi3986
    @inshazaidi3986 3 года назад

    Thank u sooo muchh bhaiyaaa
    Stay blessed

  • @techwithdeepesh5367
    @techwithdeepesh5367 2 года назад +3

    सी please लॉन्च cs series for tomorrow board paper

  • @no1shorts_
    @no1shorts_ 2 года назад +2

    One day before exam. Willl. Like 😂 👍

  • @yuvrajbhaia2939
    @yuvrajbhaia2939 3 года назад +4

    Why did we take S=[ ] , when we didn't use it anywhere in the code??

    • @thattechieguy
      @thattechieguy 2 года назад

      bro here S acts as stk for the rest of the program

  • @Param3021
    @Param3021 3 года назад +3

    Sir notes ka link daal do

  • @karandx_official
    @karandx_official 2 года назад +1

    Sir please provide the link of the code 🙏🙏

  • @musicophilic3040
    @musicophilic3040 3 года назад +7

    Can anyone please tell me where we can find new notes of wave optics by Aman bhaiya?

  • @rajkumarchoudary4819
    @rajkumarchoudary4819 3 года назад +7

    Sir,
    IP walo ka lia plz... Pythan or my SQL ka corse dalo plz...
    🙏🙏🙏🙏🙏
    I who also want...

  • @mml119
    @mml119 3 года назад +2

    Sir
    Syllabus kab complete hoga??

  • @LUCIFER-yk1jt
    @LUCIFER-yk1jt 9 месяцев назад

    Sir ' global ' variable should be used in every function definition for top. without it, it is showing error

  • @shreeyashmishra2120
    @shreeyashmishra2120 2 года назад +1

    can someone tell what's the text editor or software he's using?

  • @jackma9528
    @jackma9528 3 года назад +2

    Bhaiya yaha error dikha raha hai... It's telling that "local variable refrencedy before assignment"

    • @thattechieguy
      @thattechieguy 2 года назад

      kindly see my comment and it's reply in the comment section

  • @priyanshukumarsaw8121
    @priyanshukumarsaw8121 3 года назад +1

    Please share it's notes

  • @praveenagarwal9462
    @praveenagarwal9462 3 года назад +2

    Bhaiya wave optics ke notes aur semiconductor ke notes Bhi Daal dijiye aap RUclips par ....🙏

    • @b.harish4080
      @b.harish4080 3 года назад

      Wave optics already uploaded on discord

  • @nikhilbaisla8693
    @nikhilbaisla8693 3 года назад +2

    Bhai top ki value len-1 kaise h?

    • @thattechieguy
      @thattechieguy 2 года назад

      top kyuki top element alag se treat kiya gaya hai
      ussko special mention kiya hai

  • @ZAMislive
    @ZAMislive 3 года назад +2

    great video bro
    i laughed when the first output come, at the very first time

  • @AdityaSharma-fp8lo
    @AdityaSharma-fp8lo 3 года назад +6

    This is the most code intensive lecture.......thanks bhaiya😊😊😊😊 and pls everyone like share its dissapointing that likes are decreasing video by video.....😐😐😐😐

  • @remadas0
    @remadas0 3 года назад +1

    link to the notes not given

  • @abhiii_navvv
    @abhiii_navvv 3 года назад +1

    Bhaiya aapki Alternating current wali video ka 1st lecture chal Nhi rha h Baaki sare Chl rhe h Unacadmey app pr kuch Kro bhaiya plz plz..

  • @angadprajapati2854
    @angadprajapati2854 Год назад +1

    Bro your code means stack implementation program contains under 77 line program
    Even I have a also program under 25 to 40 lines like stack implementation and my program was too easy and understandable!!!

  • @mr.arshad9803
    @mr.arshad9803 3 года назад +1

    sir plsss give discord link jo description main thi wo wali expire ho gyi

  • @kushanchaudhary7867
    @kushanchaudhary7867 2 года назад +4

    This is the right code if you are having problem with pop :)
    --------------------------Code-------------------------------------
    s=[]
    top=None
    def isEmpty(stk):
    if stk==[]:
    return True
    else:
    return False
    def push(stk,item):
    s.append(item)
    top=len(stk)-1
    def spop(stk):
    if(isEmpty(stk)):
    return('UnderFlow!')
    else:
    i = stk.pop()
    if(len(stk) ==0):
    top=None
    else:
    top=-1
    return i
    def peek(stk):
    if isEmpty(stk):
    return('underflow')
    else:
    top=len(stk)-1
    return(stk[top])
    def display(stk):
    if(isEmpty(stk)):
    print('Stack is empty!')
    else:
    top=len(stk)-1
    print(stk[top],'

    • @keer-3
      @keer-3 2 года назад +1

      Thanks bro!

    • @samarthnegi1209
      @samarthnegi1209 2 года назад

      @@keer-3 iss saal stack implimentation tk he ayega na?
      application of stack cut ho gya?
      kya

    • @thechosenone2004B
      @thechosenone2004B 2 года назад

      me sochra tha sab to sahi kr rha hu galat kaise aa rha h, def spop try kr k dekhta hu

    • @Heritageunfolded
      @Heritageunfolded 9 месяцев назад

      Thnsksss

  • @Rose-5re
    @Rose-5re 6 месяцев назад +1

    Sir pehle h
    jinka video slow krk dekhna pad rha h

  • @nishant6809
    @nishant6809 9 месяцев назад +1

    Kon kon aj subah dekh rha(2 April)😂

  • @s2jee821
    @s2jee821 2 года назад +2

    14:09 wahi to nhi hai 😐🙃

  • @siddeshshinde7303
    @siddeshshinde7303 3 года назад +1

    Aman bhaiya please assembly language programing bhi karo na

  • @amanvedio55
    @amanvedio55 3 года назад +1

    Sir vector chapter ka vedio banaiye

  • @sayanjitb
    @sayanjitb 3 года назад +1

    How to get this code file?

  • @ashvanichaudhary9782
    @ashvanichaudhary9782 3 года назад +3

    Sir kya MySQL ki bhi classes hongi?

  • @minhadtuashimahmed3873
    @minhadtuashimahmed3873 3 года назад +1

    Yeh to bahut lamba program haii....
    Exam m stack queue se related kaise questiom ayenge???

  • @deepanshubaberval8911
    @deepanshubaberval8911 3 года назад

    Where is not of this lecture

  • @gurmankaur1060
    @gurmankaur1060 3 года назад +3

    Dosto ye %d kya h?

  • @winterfrost2467
    @winterfrost2467 3 месяца назад +1

    10 bjne wale hain aur mein pop top par rha... 🫠

  • @sathibanerjee3660
    @sathibanerjee3660 3 года назад +17

    Teacher : You don't attend my class; still you're scoring 90+ in every CS paper; what's the secret?
    Me : Sir, have you heard of Harsh Sharma of Apni Kaksha?
    Teacher : 😑😑

  • @dhyeytank835
    @dhyeytank835 3 года назад

    Where are the notes of this lecture???....not there in the description box

  • @aryankushwaha9306
    @aryankushwaha9306 3 года назад

    Bhaiya yae kya boards kae exam mae aata hai....practicals mae...plz koyi bataoo

  • @BabyBoo004
    @BabyBoo004 2 года назад

    Ye konse applicatⁿ pe code likha or run kraya??

  • @sahajpreet3448
    @sahajpreet3448 2 года назад +1

    pop is not working man even if i have changed the function name

  • @arpita6479
    @arpita6479 3 года назад +1

    Bhaiya code kaha hai description box me

    • @ehtishama3066
      @ehtishama3066 3 года назад +1

      code nhi mil rha hai, aur muje error aa rha hai

    • @arpita6479
      @arpita6479 3 года назад

      @@ehtishama3066 main de du kya code?

    • @ehtishama3066
      @ehtishama3066 3 года назад

      @@arpita6479 yes bro, please share link

  • @sythe263
    @sythe263 2 года назад

    awesome!

  • @achintyanivsarkar8419
    @achintyanivsarkar8419 3 года назад

    bhaiya IP vaalo ke liye bhi krdo kuch plz 🙏🙏🙏🙏

  • @hi7156
    @hi7156 2 года назад +4

    Bhaiya hadd se jyaada ad daalte hai 💀

  • @vectorx2003
    @vectorx2003 3 года назад +1

    Re-upload old videos of C++ for Class 12

  • @Shanghai_Shine
    @Shanghai_Shine 2 года назад

    Bhaiya Konsa version use karte ho python ka

  • @Thinkmore-ds3fq
    @Thinkmore-ds3fq 3 года назад

    thank u

  • @avinash8238
    @avinash8238 2 года назад

    Which software is this ?

  • @manthansinghrauthanof8thc543
    @manthansinghrauthanof8thc543 5 месяцев назад +1

    bro hamari teacher ne hamse sign karva liye ki 60 % stack me nahi ay to 1week ke liye suspension.

  • @goingstoppers7944
    @goingstoppers7944 3 года назад

    Notes kaha hai???

  • @Ashu_7
    @Ashu_7 3 года назад

    Si aapki theme sabse alag can please tell us about that also yeh jo identaion ki lining show krta hai iske baare main bhi basicaaly aap apne pure python ki setting bta do ek baar Please

  • @devyanjha
    @devyanjha Год назад

    Please upload notes of this lecture

  • @nursing9294
    @nursing9294 Год назад

    Sir es playlist ke poore notes toh upload kr dete..

  • @prathemeshjankwade9641
    @prathemeshjankwade9641 Год назад +1

    How many marks to pass in computer science in theory please reply

  • @priyankpatel5501
    @priyankpatel5501 3 года назад

    Maza AYA !!!!

  • @dakshjain6673
    @dakshjain6673 3 года назад +1

    Bhaiya please 🙏🙏🎉
    Jaise hi 2 Feb ko dates announce hogi CBSE ki, 12 pcm ke liye full 3 months detailed strategy bana dena subject wise please🙏🙏🙏
    Please bhaiya 🙏🙏🙏👍👍👍
    Much needed🙏🙏
    Huge request 🙏🙏
    Please think on it🙏🙏
    Don't ignore 🙏🙏🙏

  • @ShadowzSharma
    @ShadowzSharma 3 года назад

    7:20

  • @renumalik8386
    @renumalik8386 3 года назад

    Sir plz jaldi jaldi cs python ka pura syllabus kar va dijiye for baords
    As we are having our pre boards in February

  • @41.paridarshansahoo31
    @41.paridarshansahoo31 2 года назад

    which python software u r use?

  • @Thesongmate
    @Thesongmate Год назад

    Kis application pe code krte ho bta do please

  • @siyona.snotra
    @siyona.snotra 3 года назад

    khaa hai code ka link

  • @akshatjaiswal6073
    @akshatjaiswal6073 3 года назад

    Ye )practical me aa skta hai?

  • @jsbeatz1640
    @jsbeatz1640 Год назад +2

    11:25 bro fr harrassing user💀💀💀💀

  • @chitrakshimahajan7932
    @chitrakshimahajan7932 3 года назад

    Yahan %d kya hai??

  • @achaljain5969
    @achaljain5969 Год назад

    Bhaiya is code ka description pai dal do link

  • @vivaanreddy8771
    @vivaanreddy8771 9 месяцев назад +3

    heres a simpler and far better code,
    stack = []
    def push(stk, item):
    stk.append(item)
    def pop(stk):
    if not stk:
    return 'Underflow!'
    return stk.pop()
    def peek(stk):
    if not stk:
    return 'Underflow!'
    return stk[-1]
    def display(stk):
    if not stk:
    print('Stack is empty!')
    else:
    print('Top of the stack: ', stk[-1])
    print('Stack elements:')
    for item in reversed(stk):
    print(item)
    while True:
    choice = input('''STACK IMPLEMENTATION
    1. PUSH
    2. POP
    3. PEEK
    4. DISPLAY
    5. EXIT
    Enter your choice (1-5): ''')

    if choice == '1':
    item = int(input("Enter the item you want to push: "))
    push(stack, item)
    print(item,' added successfully')

    elif choice == '2':
    item = pop(stack)
    if item == 'Underflow!':
    print('Stack is empty')
    else:
    print(item,' popped from the stack')

    elif choice == '3':
    item = peek(stack)
    if item == 'Underflow!':
    print('Stack is empty')
    else:
    print('%d is at the top of the stack' % item)

    elif choice == '4':
    display(stack)
    elif choice == '5':
    break
    else:
    print('Invalid input')

    print('

    ')

    • @Pikachu83622
      @Pikachu83622 9 месяцев назад

      Bruuuh...ye yad kese hoga😂

    • @huzaifa9438
      @huzaifa9438 9 месяцев назад

      does it is correct code !?

  • @satyamkumar-wq4pj
    @satyamkumar-wq4pj 3 года назад +1

    Notes to upload kar do itne din se bol raha hu koi reply nhi diya