<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: manav shah</title>
    <description>The latest articles on DEV Community by manav shah (@manavshah123).</description>
    <link>https://dev.to/manavshah123</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F528665%2Fc973e094-7dd8-4bc7-95cd-604721c56b0b.jpeg</url>
      <title>DEV Community: manav shah</title>
      <link>https://dev.to/manavshah123</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/manavshah123"/>
    <language>en</language>
    <item>
      <title>Introduction to Python variables.</title>
      <dc:creator>manav shah</dc:creator>
      <pubDate>Thu, 24 Feb 2022 02:32:17 +0000</pubDate>
      <link>https://dev.to/manavshah123/introduction-to-python-variables-18i</link>
      <guid>https://dev.to/manavshah123/introduction-to-python-variables-18i</guid>
      <description>&lt;h2&gt;
  
  
  What is Python variable :-
&lt;/h2&gt;

&lt;p&gt;First of all, Variable is some byte of memory where any value or character is store in memory, the variable for storing data value, python has no data type, Python has no command for variable declaration, For create a variable just give a name of a variable and assign value like below,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;a = 10&lt;br&gt;
b = 19.8&lt;br&gt;
c = "SWAGBLOGGER"&lt;br&gt;
print(a)&lt;br&gt;
print(b)&lt;br&gt;
print(c)&lt;br&gt;
10 19.8 SWAGBLOGGER&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The variable doesn't need to declare with any type, also if you want to change the datatype then you can.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;a = 10      #a is a int type&lt;br&gt;
b = 19.8    #b is a float type&lt;br&gt;
c = "SWAGBLOGGER"  #c is a character type&lt;br&gt;
print(a)&lt;br&gt;
print(b)&lt;br&gt;
print(c)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Variable Names :-&lt;/strong&gt;&lt;br&gt;
A variable naming has particular no rules, but in programming, we are declared as a small name like x, y, a, b, etc... Else we are declaring a variable with meaning full name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rules for python variable&lt;/strong&gt;&lt;br&gt;
The name started with the letter or underscore character.&lt;br&gt;
Name can't start with numbers.&lt;br&gt;
Name can only start with the alpha-numerical characters and underscores.&lt;/p&gt;

&lt;p&gt;Names are case-sensitive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Legal variable name:-&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;var = "SWAGBLOGGER"  #legal variable name &lt;br&gt;
mvar = "PYTHON"   # Legal variable name&lt;br&gt;
Illegal variable name:-&lt;/p&gt;

&lt;p&gt;9var = "Jay"      #Illegal variable name &lt;br&gt;
m-var = "Manav"   #Illegal variable name &lt;br&gt;
hi var = "Riya"   #Illegal variable name &lt;/p&gt;

&lt;p&gt;Assign a value for multiple variables:-&lt;br&gt;
In python allow values to multiple variable in one line. like below,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;a, b, c ="SWAGBLOGGER" , "jay" , "manav"&lt;br&gt;
print(a)&lt;br&gt;
print(b)&lt;br&gt;
print(c)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SWAGBLOGGER jay  manav&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output variable:-&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The output variable is used to print a statement.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;a = "SWAGBLOGGER"&lt;br&gt;
b = ", simple solution for a complex problem"&lt;br&gt;
z =  x + y&lt;br&gt;
print(z)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SWAGBLOGGER, simple solution for a complex problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the global variable:-&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What is the global variable?&lt;br&gt;
Variables that are created outside of a function are known as global variables. It can be used by, both inside and outside functions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;how to create variable outside the function.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`x = "superb"&lt;/p&gt;

&lt;p&gt;def func():&lt;br&gt;
  print("Python is " + x)&lt;/p&gt;

&lt;p&gt;func()`&lt;/p&gt;

&lt;p&gt;python is superb&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to create variable inside the function.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`x = "superb"&lt;/p&gt;

&lt;p&gt;def function():&lt;br&gt;
  x = "awesome"&lt;br&gt;
  print("Python is " + x)&lt;/p&gt;

&lt;p&gt;function()&lt;/p&gt;

&lt;p&gt;print("Python is " + x)`&lt;/p&gt;

&lt;p&gt;python is awesome. python is superb&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Global keyword:-&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To create a global variable in function, you can use the global keyword.&lt;/p&gt;

&lt;p&gt;use of global keyword&lt;/p&gt;

&lt;p&gt;`def myfun():&lt;br&gt;
  global a&lt;br&gt;
  a = "fabulous"&lt;/p&gt;

&lt;p&gt;myfun()&lt;/p&gt;

&lt;p&gt;print("SWAGBLOGGER is " + a)`&lt;/p&gt;

&lt;p&gt;SWAGBLOGGER is fabulous&lt;br&gt;
Use global keyword inside the function&lt;/p&gt;

&lt;p&gt;`x = "awesome"&lt;/p&gt;

&lt;p&gt;def fun():&lt;br&gt;
  global x&lt;br&gt;
  x = "superb"&lt;/p&gt;

&lt;p&gt;fun()&lt;/p&gt;

&lt;p&gt;print("Python is " + x)`&lt;/p&gt;

&lt;p&gt;python is superb&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
