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.
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)
@@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
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)
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!
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],'
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!!!
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$$$😌
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)
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 : 😑😑
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 🙏🙏🙏
This is the most code intensive lecture.......thanks bhaiya😊😊😊😊 and pls everyone like share its dissapointing that likes are decreasing video by video.....😐😐😐😐
please🙏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 Sir, abhi tak 10-15% hi padha h{pcm me} please 3 months me kaise syllabus compelete karke revise karu?🙏🙏🙏 Please 🙏🙏🙏👍👍👍 Much needed🙏🙏 Huge request 🙏🙏 Please think on it🙏🙏 Don't ignore 🙏🙏🙏
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
kis kis ka exam kl hai???
Bhai dimg sahi hai ?sabka kal he hoga
lol mera bhi hai kl,
good luck aapko bhi 👍
Samjh ni aara kuch🤧🤧
@@24ragerude
Aaj h😅
best of luck everyone jiska bhi subah exam hai
Are you ready ?
@@letsamaze7072 nha bro
No bro
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],'
king
king
king
King ?
@@Abhinav-gu2ui king
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.
All the best to all for today's exam
11:25 the most epic part🤣🤣🤣
😂 Seriously...
All the best for you 2 april 2024 Exam ❤
pls post notes for this video notes are the best parts of the series
Abbe Yeh code h Iske koi notes thodi hain lmao
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)
Thodan jyada he 'if' use kar diya . All the best for cs exam.
@@Rbrnrntbetntybet elif hoga right?
@@MadMax-fs3cy
Haa
If ch==1 ke baad elif= 2, 3,4...etc hoga
@@MadMax-fs3cy else bhi hoga last me
if -elif - else
Item is not defined
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],'
My fav line:- "Eat well, sleep well aand study well" 😘😘😘
Mine too but except study part 🤭
Well 2nd one's most important for concentration atleast
Master roshi ki line 👍
Chhoti baacchi ho kaya 🙂
@@MonkeyDluffy-fy8xj 1 and 2 which is very important because if you do not eat well then you will not be able to sleep well.
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],'
What does %d and %item mean?
@@adityabhandari6145 check out 8:45 you will get it
@@viee488 yes but what does it mean?
itna bhagaate kyu ho yaar saare videos me
ya
Nahi bhagane par phir tum log 2x pe dekhto ho isiliye
@@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
Best in the world "Aman dhattarwal" zabardast.
12:30 most epic
NOTES UPLOAD KAR DO BHAIYA!!!!!
PRACTICALS AND PRE BOARDS H
Me : writing andhe 1.... 5dalna tha in my pre board if I've to write menu driven program for stack
My marks : Rip💔🙂
Andhe galat ch padh liya term 1 me nhi tha 😂
@@parveenparveen4565 most probably case based question or a sample code edit problems
11:23 🤣🤣🤣🤣
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
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('
')
Why we are writing top = len(stk)-1
why not top = len(stk) only
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!
Aman bhaiya zindabad....🙏🙏🙏
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],'
Thanks bro!
@@keer-3 iss saal stack implimentation tk he ayega na?
application of stack cut ho gya?
kya
me sochra tha sab to sahi kr rha hu galat kaise aa rha h, def spop try kr k dekhta hu
Thnsksss
Thanks a lot :)))
Love to the apni kaksha team
One day before exam. Willl. Like 😂 👍
सी please लॉन्च cs series for tomorrow board paper
Eat well, Sleep well and study well...🙂
are ch==5 k niche break dene se kay kisika error dikah raha h?? error- break outside the loop
10 bjne wale hain aur mein pop top par rha... 🫠
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!!!
Hey dude can u send ur Program here.
@@Patelnchora69 I am outside from home!!
@@angadprajapati2854 oh.
Bro have u reached home?@@angadprajapati2854
14:09 wahi to nhi hai 😐🙃
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$$$😌
Sir
Syllabus kab complete hoga??
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('
')
Bruuuh...ye yad kese hoga😂
does it is correct code !?
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 : 😑😑
Lol
@@harshsharma4197 😂
Thnx sir😊😊
Thank you so much Aman Bhaiya and Team 🙏🏻
Sir pehle h
jinka video slow krk dekhna pad rha h
Can anyone explain to me what this %d and %item is for?
Re-upload old videos of C++ for Class 12
Ye )practical me aa skta hai?
Sir kya MySQL ki bhi classes hongi?
videos available kindly check
Dosto ye %d kya h?
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 🙏🙏🙏
Sir pls phy ka second books ka notes dedijiye mra preboards hai
What 'bout my notes?🙈
Take it easy 😂👍
how can this code be used for string value
Sir ' global ' variable should be used in every function definition for top. without it, it is showing error
bhaiya huge huge huge request to u pls upload aldehyde ,ketones notes 🙏🙏🙏🙏🙏🙏🙏🙏
Bhai top ki value len-1 kaise h?
top kyuki top element alag se treat kiya gaya hai
ussko special mention kiya hai
Thankyou bhaiya!!☺️☺️☺️
Thank u sooo muchh bhaiyaaa
Stay blessed
Sir,
IP walo ka lia plz... Pythan or my SQL ka corse dalo plz...
🙏🙏🙏🙏🙏
I who also want...
Description mai code Kaha hain
Why did we take S=[ ] , when we didn't use it anywhere in the code??
bro here S acts as stk for the rest of the program
link to the notes not given
Sir notes ka link daal do
Bhaiya yaha error dikha raha hai... It's telling that "local variable refrencedy before assignment"
kindly see my comment and it's reply in the comment section
Please share it's notes
Sir please provide the link of the code 🙏🙏
Bhaiya hadd se jyaada ad daalte hai 💀
This is the most code intensive lecture.......thanks bhaiya😊😊😊😊 and pls everyone like share its dissapointing that likes are decreasing video by video.....😐😐😐😐
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..
Yeh to bahut lamba program haii....
Exam m stack queue se related kaise questiom ayenge???
Ye konse applicatⁿ pe code likha or run kraya??
thank you for such great lecture harsh sir you teach really well
Thanks
Where are the notes of this lecture???....not there in the description box
what is the use of %d here?
just a future reference operator ..
Bhaiya wave optics ke notes aur semiconductor ke notes Bhi Daal dijiye aap RUclips par ....🙏
Wave optics already uploaded on discord
Bhaiya Konsa version use karte ho python ka
Bhaiya yae kya boards kae exam mae aata hai....practicals mae...plz koyi bataoo
please🙏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
Sir, abhi tak 10-15% hi padha h{pcm me} please
3 months me kaise syllabus compelete karke revise karu?🙏🙏🙏
Please 🙏🙏🙏👍👍👍
Much needed🙏🙏
Huge request 🙏🙏
Please think on it🙏🙏
Don't ignore 🙏🙏🙏
CHUD GYI DIDI TUM TO XD
Can anyone please tell me where we can find new notes of wave optics by Aman bhaiya?
Discod server☺
@@munmun2830 kon sa?
Please upload notes of this lecture
Agli baar se mai bhi 'Andhe 1-5 daalna tha' hi dalunga else condition me🤣
Aman bhaiya please assembly language programing bhi karo na
Yahan %d kya hai??
Andhe 1-5 daalna tha...😂😂
Notes kaha hai???
Which software is this ?
Where is not of this lecture
sir plsss give discord link jo description main thi wo wali expire ho gyi
pop is not working man even if i have changed the function name
Kon kon aj subah dekh rha(2 April)😂
thank u
great video bro
i laughed when the first output come, at the very first time
can someone tell what's the text editor or software he's using?
Vs text editor
@@shreeyansh-x5l thanks man
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
use ide provided by jetbrains
Sir vector chapter ka vedio banaiye
Maza AYA !!!!
Sach h na
Sir es playlist ke poore notes toh upload kr dete..
Sir plz jaldi jaldi cs python ka pura syllabus kar va dijiye for baords
As we are having our pre boards in February
Hare Krishna hare Krishna Krishna Krishna hare hare
Hare ram hare ram ram ram hare hare
Good vid par Top top bol ke irritate kr diya yaar. 🤦
How many marks to pass in computer science in theory please reply
23.5
24
Bhai 20 ka kardega to 4 extra badha dete hai 🎉
which python software u r use?
vs text editor
Sounds like @flyingbeast
Notes???
NOTES??
Bhai java k liye bhi kuch
Kis application pe code krte ho bta do please
Vs code
bhaiya IP vaalo ke liye bhi krdo kuch plz 🙏🙏🙏🙏
How to get this code file?
diy