Python DataTypes


Video Lecture


Every value that you assign in Python has a datatype. Since everything is an object in Python programming, so data types are actually classes, and variables are instance (object).

Python has various data types, some are listed below −

  1. Numbers
  2. Boolean
  3. String
  4. List
  5. Tuple
  6. Set
  7. Dictionary

Python Numbers :

This data type supports only numerical values like 1 , 31.4 .

Python3 support 3 different numerical types.

  1. int : for integer values like 5 .
    a = 5
  2. float : for floating point values like 3.14 .
    a = 3.14
  3. complex : for complex numbers like 1+2j .
    a = 1 + 2j


Python Boolean :

In Python True and False are boolean literals.

But the following values are also considered as False.
0 – zero , 0.0 ,
[] – empty list , () – empty tuple , {} – empty dictionary , ” None"

>>> b = True
>>> type(b)
<class 'bool'>
>>> b = False
>>> type(b)
<class 'bool'>
>>> 

Python String :

Strings in python are contiguous series of characters.

We can use single quotes or double quotes to represent strings.

Multi-line strings can be denoted using triple quotes, ''' or """.

>>> s = "Prowess Apps "
>>> s = 'Prowess Apps'
>>> s = '''This is python tutorial
	   on prowessapps.in'''
>>>
learn more >>>


Python List :

A list contains items separated by commas and enclosed within square brackets ([ ]).

>>> a = [1, 2, 3, 4]
# you can have different types in list
>>>  a = [1, 2.3, 3.4, 4]
>>>
learn more >>>


Python Tuple :

Tuples are immutable, contains items separated by commas and enclosed within parentheses ( ).

>>> a = (1, 2, 3, 4)
# you can have different types in tuple
>>>  a = (1, 2.3, 3.4, 4)
>>>
learn more >>>


Python Set :

Set contains items separated by commas and enclosed within curly brackets { }.

>>> a = {1, 2, 3, 4}
# you can have different types in tuple
>>>  a = {1, 2.3, 3.4, 4}
>>>
learn more >>>


Python Dictionary :

Dictionary is a collection which works on a key-value pair.

Dictionaries are enclosed by curly braces ({})

>>> d = {'k1':'v1', 'k2':'v2', 'k3':'v3'}
>>> type(d)
<class 'dict'>
>>> print(d)
{'k1': 'v1', 'k2': 'v2', 'k3': 'v3'}
>>>
learn more >>>






 






Training For College Campus

We offers college campus training for all streams like CS, IT, ECE, Mechanical, Civil etc. on different technologies like
C, C++, Data Structure, Core Java, Advance Java, Struts Framework, Hibernate, Python, Android, Big-Data, Ebedded & Robotics etc.

Please mail your requirement at info@prowessapps.in


Projects For Students

Students can contact us for their projects on different technologies Core Java, Advance Java, Android etc.

Students can mail requirement at info@prowessapps.in


CONTACT DETAILS

info@prowessapps.in
(8AM to 10PM):

+91-8527238801 , +91-9451396824

© 2017, prowessapps.in, All rights reserved