Python variables in nutshell

in #new6 years ago

Variables are nothing but reserved memory locations to store values.

Python has no command for declaring a variable, unlike any programming language.
variable is created the moment you first assign a value to it.
For example-

x = 5
y = "John"
print(x)
print(y)

Variable Naming convention :

  1. Variable name must starts with letter or underscore.

  2. Variable name cannot start with numbers or any special characters.

  3. A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )

  4. Variable names are case-sensitive (age, Age and AGE are three different variables)

Python uses the + character To combine both text and a variable:
Example-

x = "awesome"
print("Python is " + x)

We can also use the + character to add a variable to another variable:

x = "Python is "
y = "awesome"
z = x + y
print(z)

We cannot combine string and numbers, python will generate error, like following code does :

Example
x = 5
y = "John"
print(x + y)

Python allows you to assign a single value to several variables simultaneously. For example −
a = b = c = 1
a = b = c = 1, 2, "john"

Python has five standard data types −

Numbers
String
List
Tuple
Dictionary

All data types we will cover in comming blogs.

python-training-500x500.png

Sort:  

Congratulations @anand1! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of comments

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard!


Participate in the SteemitBoard World Cup Contest!
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: @good-karma and @lukestokes


Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

You have a minor misspelling in the following sentence:

All data types we will cover in comming blogs.
It should be coming instead of comming.

It's natural Because i am human not a bot like you

Coin Marketplace

STEEM 0.28
TRX 0.13
JST 0.032
BTC 61060.27
ETH 2927.58
USDT 1.00
SBD 3.55