Variables in python

Variables in python:

Variable:  it is a thing which going to store something.
- we can say that variable is a container that stores something.
ex: name = “Zaheer”
age = 24
here, name and age are variables. and “ = “ is an assignment operator to assign values to the variable.

- you can choose any name for a variable but, while we are working in a company or with a team then we should follow some rules and guidelines

◆   While we are working In a company we always have to follow some rules
◆   That means you have to write the code in such a manner (that is not only for u to understand)but it should be everyone in a team or in a company.
◆   Python is case-sensitive,   means   ex: [ name, NAME, Name, _name, _NAME ]

◆   The name of the variable always starts with a small or by capital letter it can’t start with any numbers or any special characters.

◆   In python, only one special character can be allowed to use as first the character of the variable that is “underscore  _ “.
◆   here,name1=“Zaheer”  can be a variable but,  1name=“Zaheer”   can’t be a variable

◆    if you are going to a store  such as for ex: your first name

First_name  (--it is correct)

First  name  (--- it is wrong)

◆   In the same way, we have

First-name
First_Name

Last-name
We can store in this way
Last_name

◆   Assigning a single variable
name=“Zaheer”

◆   Assigning multiple variables
name, age = “john”, 10

◆   And same values for multiple variables
fname = lastname =middlename  = “zaheer”

◆Comments :

“ # “we can make a single line comment

for multiple comments: 
#for multiple comments
"""
-------
-------

"""

note:

-  whenever you are going to store a string that will always be in a quoted. you can use a single as well as double quotes
- single-quote for when you are going to assign  a word


ex:‘a’ -word

“I am learning python“ -sentence.

"""for to store a paragraph or
 to make it as a comment"""

 

No comments:

Post a Comment