#36 Python Tutorial for Beginners | Global Keyword in Python | Global vs Local Variable

  Рет қаралды 514,367

Telusko

Telusko

Күн бұрын

Check out our courses:
Spring and Microservices Weekend Live Batch : bit.ly/spring-live-weekend
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : bit.ly/java-spring-cloud
For More Queries WhatsApp or Call on : +919008963671
website : courses.telusko.com/
Instagram : / navinreddyofficial
Linkedin : / navinreddy20
TELUSKO Android App : bit.ly/TeluskoApp
Discord : / discord
In this lectre we are discussing:
#1 Scope of variable
#2 Local variable
#3 Global variable
#4 Global keyword
#5 Global() function
#1 Scope of variable
-- scope of variable means where we can access the variable
-- there are two types of scope of variable
1. local scope
2. global scope
#2 Local variable
-- local variable means variable which is defined inside the function
-- we can access the local variable inside the function only
-- we cannot access the local variable outside the function
Local Scope:
When a variable or function is defined inside a function, it is said to be in the local scope of that function.
Variables defined in the local scope are only accessible within that function and are destroyed once the function
completes execution. Local variables have the highest priority in accessing over global variables of the same name.
def func():
x = 10
print(x)
func()
-- the variable x is defined inside the function, and it can only be accessed within the function.
#3 Global variable
-- global variable means variable which is defined outside the function
-- we can access the global variable inside the function
-- we can access the global variable outside the function
x = 10
def func():
print(x)
func()
-- the variable x is defined outside the function, and it can be accessed within the function.
#4 Global keyword
-- if we want to access the global variable inside the function and we want to change the value of
global variable inside the function then we have to use global keyword.
x = 10
def func():
global x
x = 15
print(x)
func()
-- in this case no new variable is created inside the function,
but the global variable x is accessed and modified inside the function.
#5 Global() function
-- if we want to access the global variable inside the function and we want to change the value of global variable
inside the function then we have to use global() function.
e.g
x = 10
def func():
x = 15
print("local x: ",x)
y = globals()['x']
print("global x: ",y)
globals()['x'] = 20
-- using globals()['x'] we can access the global variable x inside the
function and we can change the value of global variable x inside the function.
Python Tutorial to learn Python programming with examples
Complete Python Tutorial for Beginners Playlist : • #1 Python Tutorial for...
Python Tutorial in Hindi : • #1 Python Tutorial | I...
Github :- github.com/navinreddy20/Python-
Java and Spring Framework For beginners with Spring Boot : - bit.ly/3LDMj8D
Java Tutorial for Beginners (2023) :- bit.ly/3yARVbN
Subscribe to our other channel:
Navin Reddy : / @navinreddy
Telusko Hindi :
/ @teluskohindi

Пікірлер: 338
@aravindor
@aravindor 5 жыл бұрын
No trash talk, straight to topic , optimal speed and able to explain the concept within 10 minutes . This guy is a gem 💎. Respect 🙏
@eswarsainath647
@eswarsainath647 4 жыл бұрын
Exactly same opinion!!
@dipikapandya3163
@dipikapandya3163 3 жыл бұрын
So true
@Varad_Govindu
@Varad_Govindu 2 жыл бұрын
Yup
@commentator1338
@commentator1338 2 жыл бұрын
That's not actually what trash talk means but I see what you mean
@numerousoriabure459
@numerousoriabure459 Жыл бұрын
Swrs mann
@harshnandu102
@harshnandu102 4 жыл бұрын
Great sense of humour and teaching skills! Keep going !
@dipikapandya3163
@dipikapandya3163 3 жыл бұрын
Very true
@harshabasavaraju4609
@harshabasavaraju4609 4 жыл бұрын
Plzz give him a like bezz no one will teach like this if we pay also 🙏🙏 God bless you and your family sir :)
@christianihechi
@christianihechi Ай бұрын
Still one of the best tutors even in 2024. Thank you Navin !
@vaibhavsoni4680
@vaibhavsoni4680 Жыл бұрын
This 10 min video >>>>>>> 2-3 hours of college lecture Thank you so much sir ❤
@karthik3778
@karthik3778 5 жыл бұрын
I will definitely recommend your tutorials to a python beginner sir.
@PassionateSaksham
@PassionateSaksham 2 жыл бұрын
These 8 minutes tought me 40 minutes of lecture.. Hats Off To You Sir!
@anuragray6924
@anuragray6924 Жыл бұрын
Why youtube was not there during my college days. Life would have been so easy. And I must say, you are a very good teacher. I wish you get some cards on Sep 5th every year.
@40_jaishreerana45
@40_jaishreerana45 2 жыл бұрын
Sir you are an outstanding teacher Hard to find people like you who provide help to the students , that too free of cost Very appreciable Thanks once again
@nirmalkatiyar701
@nirmalkatiyar701 4 жыл бұрын
Great job sir ! you r providing us such precious video lectures for free . I'm heartily thankful to u. 🤗
@dance90524
@dance90524 6 жыл бұрын
I really appreciate your efforts and your determination!! You and newboston were the reasons i got comfortable in programming!!👌🏻
@comelyebenezer579
@comelyebenezer579 4 жыл бұрын
You know new boston I like him too, can you recommend any of his other courses
@LoneWolf-ng6lb
@LoneWolf-ng6lb 5 жыл бұрын
The dislikers must have hold the phone in reverse
@RandomVideos_YT
@RandomVideos_YT 4 жыл бұрын
I did tbe same thing thing with ur comment in believe me i liked ur comment... 😂😂😂😅
@preethikadambala2595
@preethikadambala2595 4 жыл бұрын
🤣🤣🤣🤣🤣🤣
@vaishnavi7203
@vaishnavi7203 3 жыл бұрын
😂
@akashdoijode04
@akashdoijode04 2 жыл бұрын
Probably yes😂😂
@chanbasha3984
@chanbasha3984 2 жыл бұрын
Or May b they're Rats 😅😂
@etamecyriac1726
@etamecyriac1726 5 жыл бұрын
You have earned a new sub👍. Am still at 2 mins into your video and already amazed. Gracias
@thenukewijesinghe8234
@thenukewijesinghe8234 4 жыл бұрын
Great work !! Straight in to the topic , no bla bla blas . I love it ❤️ thanks man
@firasathali8044
@firasathali8044 4 жыл бұрын
super sir, your videos are crisp and contented. The way you teach is far better than a lot of paid courses avaialble in market. i wish i could find your videos earlier in my life. deep respect 👏👏
@shamstabrez2986
@shamstabrez2986 4 жыл бұрын
Apki jitni tarif ki jaye kam h but main apse yhi rqust krunga k ap aise hm jaise.kmzor students k liye video banate rhe its rlly helpful.for us kisi r ka toh pta nhi pr mere liye bht bht zyada beneficial tha ye so thnk u vry much
@valentinerethinam5556
@valentinerethinam5556 2 жыл бұрын
Explained wonderfully!!! After watching your video once, When I tried to write code for this , I got some doubts and then I watched your video again , Where you have neatly explained / answered all my doubts already. Thank u so much for your videos !!
@sanijawijesinghe6299
@sanijawijesinghe6299 3 жыл бұрын
Heard this from multiple people, understood for the first time, thanks a lot
@guillermoriveranunez5974
@guillermoriveranunez5974 Ай бұрын
One of the best explanations possible to anything, thank you man!
@JamesHalpert8555
@JamesHalpert8555 5 жыл бұрын
looking forward to see more of your tutorials....simply awesome!!!
@Nalanarud
@Nalanarud Жыл бұрын
Awesome man, I was stuck for 1 hour on that, tyvm
@WednesdayADAM-qp8ev
@WednesdayADAM-qp8ev 6 ай бұрын
I'm a pcb student done my graduation in chemistry but wanted to learn python ❤ and this video playlist is really helpful gor me ❤
@officesuperhero9611
@officesuperhero9611 5 жыл бұрын
You’re a great teacher. I really learn a lot from you. 🙏. Thanks
@gfunkonthecheesetree
@gfunkonthecheesetree 4 жыл бұрын
Dude, you are the man! Every one of your videos help me
@itcodingman
@itcodingman 2 жыл бұрын
讲得非常好
@rishabhraizada8812
@rishabhraizada8812 3 жыл бұрын
what a skill to teach the programming. As you said in the first video learn how to programming in fun way. hats off
@pavanjain2178
@pavanjain2178 6 жыл бұрын
We really appreciate you sir you do hardwork for us thankyou sir salute to you👏👏
@sayedrezaomid1305
@sayedrezaomid1305 4 жыл бұрын
Hello This is Omid from Aghanistan Navin sir you are the best and legend to the world of programming please provide us like this tutorial in JAVA Script and Mobile Application as well.
@shamstabrez2986
@shamstabrez2986 4 жыл бұрын
N ye aravind bhai ne sahi kaha ap gem ho bhai r hm jaise kamzor student ap jaise great logon se sikh lekr lyf mein kuch krskte h main apka ehsan toh nhi chuka skta bcoz u r my tchr but i pray for u dat Allah bless u always n ap jo chaho woh apko mile in shaa Allah ta aala
@kodidatascientist6978
@kodidatascientist6978 Жыл бұрын
Offo man. You are nice guy and concept are cleared in 10 min. god bless you man. I am big fan of your way of teaching.
@kpsanjna
@kpsanjna Жыл бұрын
Navin Sir...U r Ultimate...the concepts are crystal clear within seconds...Every sec is worth watchin .... U r Truly a gem🔷..Thank u so much for the series..
@sanjeevKumar-eg6hp
@sanjeevKumar-eg6hp 2 жыл бұрын
Sir your tuturioals are the best their very precise to the point, so not even a second of your lecture is not important and also its very helpful how make these videos and teach us in a very simple manner
@shamstabrez2986
@shamstabrez2986 4 жыл бұрын
Hello bro bolun ya sir actlly ap dono hi ho mere liye bade bhai jaise b r teacher b qki i learned python by you n u did reallt fantastic job bro srusly itna zabardast tarike ka explaination ek ek chiz jo batani chhye the for d beginners apne bataya kisi ko psnd aye na aye ya kisi ne kuch sikha ho ya na sikha ho maine mgr sikh liya python ka pura concept apse all thnx to u hats off to ur explaination lyk main hr video pr toh jakr.cmmnt nhi krskta isilie isi jagah sb shre krra hun maine apka har ek video dkha h notes down kiya h n srusly bht bht bht kuch sikhne ko mila
@manognanalluri931
@manognanalluri931 4 жыл бұрын
U r making us enthusiastic about the subject.. thank you sir
@vishwanath-ts
@vishwanath-ts 5 жыл бұрын
Thank you soo much sir you saved my life I watched 100s of videos no one explained clearly how to access the variables which are inside the function from outside. Then I got your video, I liked and subscribed immediately after my problem was cleared, I'm new to python. 🙏
@cannonbolt2595
@cannonbolt2595 4 жыл бұрын
What's ur progress now? And how would you recommend me to learn python?
@applymarket934
@applymarket934 3 жыл бұрын
It was the best video I have seen for local & Global variable Description! Many thanks!
@ritu8136
@ritu8136 4 жыл бұрын
Best lecture of learn programming .Thank you soo much sir☺
@MayankSharma-jl6rc
@MayankSharma-jl6rc 3 жыл бұрын
Sir ,you are making an extraordinary effort by bringing up such a nice video on python on free of cost !!, even paid video would become fail in front of your efforts!!
@jamesbrown6591
@jamesbrown6591 4 жыл бұрын
Great video, thank you Navin!
@PrasanthJoseph
@PrasanthJoseph 5 жыл бұрын
thank you sir for clear and detailed video
@latishsaai9757
@latishsaai9757 3 жыл бұрын
bro meru chala bhaga teach chestunaru keep it up
@ygproduction8568
@ygproduction8568 4 жыл бұрын
This video was super helpful sir. Thank you very much for the video. I think I would have quit learning python if this video did not existed. So thank you so much once again
@gustavobarbosa906
@gustavobarbosa906 Жыл бұрын
i’ve seen a quite a few videos on variable scope, not one of them mentioned globals(). Thank you for one more useful lesson!
@binayraj123
@binayraj123 3 жыл бұрын
Probably the best i saw to understand this concept! thanks!
@arijitgayen8995
@arijitgayen8995 4 жыл бұрын
this videos helps more than courses from top sites
@b.sasikumar2141
@b.sasikumar2141 4 жыл бұрын
Im am practicing deligently sir for not making any mistakes tq sir for giving us free tutorials..... 🤝🤝
@Tapes44
@Tapes44 4 жыл бұрын
sir your teaching so awesome !... i can understand it clearly ...thank you very much sir !
@harshitjain7060
@harshitjain7060 5 жыл бұрын
Your videos are best sir !!
@monishdx
@monishdx 3 жыл бұрын
I was reading automate the boring stuff and got stuck on this topic. Thanks, your video is really helpful.
@ramprasath4050
@ramprasath4050 3 жыл бұрын
vera level sire......pakka teaching.....
@harshalmali856
@harshalmali856 4 жыл бұрын
really cool teaching understand all concept in just one watch
@anandvardhan4996
@anandvardhan4996 4 жыл бұрын
Exceptional explanation in short 5-10 min videos.
@shubhadeepseth2738
@shubhadeepseth2738 3 жыл бұрын
Thankyou sir...the local & global variable concept now seems more easier
@chinmaydas4053
@chinmaydas4053 6 жыл бұрын
Great sir 🙏🙏.. Your videos are always concise, deep knowledgeable and elaborative.. now with nice animation graphics.. Just the best sir 👍👍🤗..
@shivankitss8396
@shivankitss8396 3 жыл бұрын
Couldn't have explained it any better 👏. Thanks
@saranya1826
@saranya1826 5 жыл бұрын
I don't know why people dislike this video....Very informative video sir..Thank you so much....
@durgasatyavenikola2705
@durgasatyavenikola2705 3 жыл бұрын
I appreciate your clear concept of teaching ❤️👌
@sushith2205
@sushith2205 4 жыл бұрын
i was really not understandig this topic but indeed this video is really helpful and clarified my problems BIG THUMBS UP!!
@stockfish3379
@stockfish3379 4 жыл бұрын
I don't know why bt I couldn't stop myself laugh at ur expressions 🤣🤣 btw u r brilliant teacher 👩‍🏫‍💖
@mrlokeshkumar76
@mrlokeshkumar76 3 жыл бұрын
YOU ARE DOING A COMMENDABLE JOB SIR👏👏
@prathammishra4480
@prathammishra4480 4 жыл бұрын
You are awesome sir ..... no one can teach as you can
@Azzufunnyguy
@Azzufunnyguy 5 жыл бұрын
Great. Thanks for the clarification Navin. Keep it up. Now i am gonna follow you !!!
@dipikapandya3163
@dipikapandya3163 3 жыл бұрын
I have also started to follow him
@proxxy3933
@proxxy3933 Жыл бұрын
this playlist is heaven thanku so much sir.
@hrishihatolkar1944
@hrishihatolkar1944 5 жыл бұрын
I would love if all Universities will learn teaching and knowledge sharing techniques from u..
@QFGEE
@QFGEE 3 жыл бұрын
Love the enthusiasm and info.
@AbhishekSharma-dp2ie
@AbhishekSharma-dp2ie 4 жыл бұрын
thank you sir.i needed this
@niteshsoni2282
@niteshsoni2282 5 жыл бұрын
Awesome teaching
@sauravjain2925
@sauravjain2925 5 жыл бұрын
Good work, as always.
@osuracaldera
@osuracaldera 5 жыл бұрын
You are the best! Thanks very much!
@yasinbastug6753
@yasinbastug6753 3 жыл бұрын
I was so happy to understand this topic. Thank you so much for helping me learning python
@easydatascience2508
@easydatascience2508 Жыл бұрын
You can try mine too. The channel has both Python and R playlist. Video is made up with a style combining ppt and coding window. Step by step sequentially arranged videos by section numbers. The channel has another playlist for R beginning level.
@shivambhati6754
@shivambhati6754 6 жыл бұрын
Sir you are doing great work
@subhayansinha4417
@subhayansinha4417 4 жыл бұрын
very clearly explained. Thank you so much!
@karthikkeyansmk2727
@karthikkeyansmk2727 3 жыл бұрын
today i feel , i learnt new. Thank you !!
@jagadeeshwali6875
@jagadeeshwali6875 5 жыл бұрын
Thank you soo much sir.. now i m big fan of you
@nakulmehta6309
@nakulmehta6309 Жыл бұрын
You solved a great problem for me, thanku you so much
@salarghaffarian4914
@salarghaffarian4914 3 жыл бұрын
Awesome!
@naveenpolasu4670
@naveenpolasu4670 5 жыл бұрын
Awesome videos bhayya
@szmigiellus
@szmigiellus 4 жыл бұрын
I really needed this!
@ahmedaj6264
@ahmedaj6264 5 жыл бұрын
Your vedio are best sir !thanks alot off
@mohitsingh2242
@mohitsingh2242 2 жыл бұрын
Thank you for the great explanation.🙏😀
@JAIGANESH-gd3qj
@JAIGANESH-gd3qj 4 жыл бұрын
I liked this video a lot compared 2 others super😊very informative
@avinashmaurya7227
@avinashmaurya7227 2 жыл бұрын
This helps me a lot , Thankyou🌻
@beehack
@beehack 5 жыл бұрын
Thanks man thank you so much
@tymothylim6550
@tymothylim6550 2 жыл бұрын
Thanks a lot for the video! Excellent explanation:)
@muhammadhashir7949
@muhammadhashir7949 2 жыл бұрын
Thanks for getting me understanding this hectic
@deepakkumarbehera7493
@deepakkumarbehera7493 4 жыл бұрын
Really helpful ❤️❤️❤️
@raghavbansal3871
@raghavbansal3871 5 жыл бұрын
great effort sir and team
@Asoville18
@Asoville18 6 ай бұрын
This is great. Thank you.
@harshamannem5006
@harshamannem5006 11 ай бұрын
Great videos. Learning lots. However the topic of global vs local was challenging to follow especially the globals().
@vakhariyajay2224
@vakhariyajay2224 2 жыл бұрын
Thank you very much. You are a genius.
@sinarezaei218
@sinarezaei218 2 ай бұрын
thank you your explanation was great
@tridoan8140
@tridoan8140 2 жыл бұрын
Very helpful, thank you so much
@slonbeskonechen8310
@slonbeskonechen8310 3 жыл бұрын
Great thanks!
@sanjeevyadav5513
@sanjeevyadav5513 5 жыл бұрын
Sir, your the best.
@BrownManClothingCo
@BrownManClothingCo 4 жыл бұрын
Great videos. Learning lots. However the topic of global vs local was challenging to follow.
@harshamannem5006
@harshamannem5006 11 ай бұрын
Yeah! i too agree
@harshchaudhary743
@harshchaudhary743 3 жыл бұрын
Great !!
@nayeersamsi808
@nayeersamsi808 4 жыл бұрын
not sure how some one can dislike ,, it is the best video for free
@avinashwagh1058
@avinashwagh1058 3 жыл бұрын
its more straight and on the point
@adolfhitler2155
@adolfhitler2155 Жыл бұрын
you're so cool i love your videos man!
@MohitKumar-kh6mv
@MohitKumar-kh6mv 3 жыл бұрын
Awesome Awesome Aweosme
Why You Shouldn't Use the Global Keyword in Python
17:59
Tech With Tim
Рет қаралды 47 М.
Mom's Unique Approach to Teaching Kids Hygiene #shorts
00:16
Fabiosa Stories
Рет қаралды 35 МЛН
Spot The Fake Animal For $10,000
00:40
MrBeast
Рет қаралды 186 МЛН
WHAT’S THAT?
00:27
Natan por Aí
Рет қаралды 14 МЛН
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 7 МЛН
What is Scope in Python??
10:25
b001
Рет қаралды 47 М.
#63 Python Tutorial for Beginners | Exception Handling
15:59
Telusko
Рет қаралды 507 М.
#38 Python Tutorial for Beginners | Fibonacci Sequence
8:01
Telusko
Рет қаралды 778 М.
What is Python scope resolution? 🔬
5:34
Bro Code
Рет қаралды 30 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1,1 МЛН
НОВЫЕ ФЕЙК iPHONE 🤯 #iphone
0:37
ALSER kz
Рет қаралды 353 М.
Опасность фирменной зарядки Apple
0:57
SuperCrastan
Рет қаралды 11 МЛН
تجربة أغرب توصيلة شحن ضد القطع تماما
0:56
صدام العزي
Рет қаралды 63 МЛН