Variables and Data types in Python

What is variables ?

A variable is a name given to a memory location in a program.

Example : –

a = 5

b = "This is a string"

c = 4.5
Python

variable is use to contain a value.

What is keyword ?

Predefine or reversed words in programmming languages are called keywords.

ex  print(), input() etc all are keywords.

What is identifier ?

An identifier is nothing but a name assigned to an element in a program. Example, name of a variable, function, etc. Identifiers are the user-defined names . As the name says, identifiers are used to identify a particular element in a program.

Data Types in python

Data type identify the type of variable. Data type is an important concept. Variables can store data of different types, and different types can do different things.

 

Basic Data Types in Python :

  1. Integer – a number without decimals ( 1, 55, 234 )
  2. Float – a number with decimals values ( 2.4, 5.8 )
  3. Strings – A set of characters called strings ( this is a string ) and strings are written inside the double or single quotes
  4. Booleans :- True or False
  5. None :- Doesn’t not contain any value.

Python is a fantastic programming language that automatically identifies the type of variables

Example :-

a = 71 ( identifies as <int>) means it is an integer value

b = 2.5 (identifies as <float> ) means it is a floating number.

c = “string” ( identifies as <str> ) means it is a string value

Type casting using Type() function.

Type() function is use to find the data type of a variable in python

example :-

a = 8

print(type(a))

b =7.3

print(type(b))

c = "string"

print(type(c))
Python

Output : –

<class 'int'>
<class 'float'>
<class 'str'>
Markup

Note : – Every thing in python is an object.

Comments

Popular posts from this blog

⚠️How to create a virus in termux app ?

List in Python

How To Install Metasploit In Termux App ?