<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Golbal | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/golbal/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Wed, 28 Sep 2022 16:52:57 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>Golbal and local variable</title>
		<link>https://studentprojects.in/software-development/golbal-and-local-variable/</link>
					<comments>https://studentprojects.in/software-development/golbal-and-local-variable/#respond</comments>
		
		<dc:creator><![CDATA[Shubhajna Rai]]></dc:creator>
		<pubDate>Wed, 28 Sep 2022 16:52:56 +0000</pubDate>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Golbal]]></category>
		<category><![CDATA[local variable]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9611</guid>

					<description><![CDATA[<p>Local Variable: A local variable is a variable that is declared inside of a function or loop. When we define a variable within a function, its scope is limited to the function. This is the case with functions. From the time it is defined until the function&#8217;s conclusion, it is accessible. It will endure while</p>
<p>The post <a href="https://studentprojects.in/software-development/golbal-and-local-variable/">Golbal and local variable</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Local Variable:</p>



<p>A local variable is a variable that is declared inside of a function or loop. When we define a variable within a function, its scope is limited to the function. This is the case with functions. From the time it is defined until the function&#8217;s conclusion, it is accessible. It will endure while the function is running. Access to local variables from outside the function is prohibited. The function&#8217;s parameter names have the same behavior as local variables.</p>



<p>Example:</p>



<p>def sum():</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a=10 #local variable cannot be accessed outside the function</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b=20</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum=a+b</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print( sum)</p>



<p>print(a) #this gives an error</p>



<p>It will give you an error if you attempt to access variable &#8220;a&#8221; outside of the function. It can only be accessed within the function.</p>



<p>Globe variable:</p>



<p>A global variable, on the other hand, is simpler to comprehend because it is accessible throughout the program and is not specified inside the function. It can alternatively be described as a variable that is defined in the program&#8217;s main body. Any loop or function may call it. Anywhere in the software is within its scope.</p>



<p>Example:</p>



<p>a=1&nbsp; #global variable</p>



<p>def print_Number():</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a=a+1;</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(a)</p>



<p>&nbsp;print_number()</p>



<p>This is due to the fact that we can only access the global variable; inside the function, we are unable to change it.</p>



<p>The global keyword in Python enables us to change the global variable. It is employed to establish a global variable and make local changes to the variable.</p>



<p>Rules of the global keyword:</p>



<p>Unless specifically designated as global, any value we assigned to a variable within the body of a function would be considered local Implicitly global variables are those that are exclusively used inside of functions. The global keyword shouldn&#8217;t be used outside of functions.</p><p>The post <a href="https://studentprojects.in/software-development/golbal-and-local-variable/">Golbal and local variable</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/golbal-and-local-variable/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
