Variables and Data Types

By jpraj0268 Jan 26, 2024

Variable Assignment

  • When you create a variable you keep some space in memory. These memory locations are then used to store values.
# define a variable name "a" and assign value 5 to it
a = 5
  • To view some data on the output screen, python also has print function. Using print function we can control the view on the output screen.
print(a)

Variable naming rules

Identifiers in Python

  • Like Variables, we have to define functions, classes, etc in python. Naming them helps to differentiate one entity from another.
  • All these names given to these entities are known as Identif
  • Python have some rules to define the Identifiers.

Rules of Writing Identifiers

  • Python is case sensitive language.
  • Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore _. Names like myVariable, var_1 and print_this, all are valid example.
  • An identifier cannot start with a digit.
  • 1variable is invalid, but variable1 is perfectly fine.
  • We cannot use special symbols like !, @, #, $, % etc. in our identifier. _ is allowed.

Keywords cannot be used as identifiers. `Keywords` are the reserved words in Python.

Keywords in Python

  • False
  • class
  • finally  
  • is    
  • return
  • None  
  • continue  
  • for  
  • lambda    
  • try
  • True, etc

Data types

  • int
  • string
  • float
  • bool

To check the data type of a variable

Another Example

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *