codescracker


python

Python Data Types



« Previous Tutorial Next Tutorial »


Basically data type represents the type of value and determines how the value can be used in a python program.

There are following five standard data types available in Python programming:

You will learn all about the above listed data types available in Python later in separate tutorials.

Python Data Type Example

Here are some examples of number data type in Python.

i = 10
f = 23.43
total = 987

Here is an example of string data type in Python.

str = "Hello World, I am Python Data Types"

Here is an example of list data type in Python.

list = [10, 20, 30, 'hi', 'hello', 43.23, 432.42, 'python']

Here is an example of tuple data type in Python.

tuple = (10, 20, 30, 'hi', 'hello', 43.23, 432.42, 'python')

Here is an example of dictionary data type in Python.

dict = {'number': 10, 'code': 20, 'name': 'python'}

Let's take an example of data type in Python. This example contains, integer, floating-point, and string type value to the variable namely int_var, float_var, and str_var.

# Python Data Type Example
int_var = 10;
float_var = 10.40;
str_var = "This is Python Data type Tutorial";
print("Values are:\n",int_var,"\n",float_var,"\n",str_var);

Here is the sample output of the above data type example in Python:

python data types

More Examples

Here are some conversion program examples, you may like:


« Previous Tutorial Next Tutorial »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test