Skip to main content

Command Palette

Search for a command to run...

Basics Of Python -2

Published
2 min read
Basics Of Python -2
P

Hello, I'm Priya Chakraborty, a dedicated B.Tech student in Electrical Engineering at Siliguri Institute Of Technology. I'm an enthusiastic learner, constantly seeking to expand my skill set and knowledge base. With a solid foundation in programming languages such as C, R, Python, and MySQL, I'm poised to tackle complex technical challenges.

But my passions extend beyond the realm of engineering. I'm also an aspiring content writer, driven by a curiosity to communicate ideas, both technical and non-technical, in a way that captivates and educates.

My journey is defined by a relentless pursuit of self-improvement, coupled with strong communication skills. I believe in the power of continuous learning and the importance of sharing knowledge.

DAY 2:

In this blog, you will get to know about the basic data types of python.

DATA TYPES
Data types are nothing but the classification of the data items in python. Like by using data types, we get to know about the class of that particular data.

There are different types of in-built data types in python. We will discuss it with examples.

DATA TYPES IN PYTHON:

  1. Numeric

  2. Boolean

  3. Sequential

  4. Dictionary

  5. Set

  1. Numeric -

Numeric data types in python define a numerical class.

  • Integer

  • Float

  • Complex

Integer

n=45
print(type(n))

output :

Float

n=5.01
print(type(n))

output :

Complex

n=5.01+1j
print(type(n))

output :

These are the numeric data types in python.


  1. Boolean

Boolean data types are whether the object is true or false.

print(type(True))

output :

print(type(False))

output:

It is very important, to write the first letter of "True" in capital "T", and "False" in capital "F", otherwise you may get an error.

  1. Sequential

Sequential data types are the ordered collection of data items.

  • String

  • List

  • Tuple


String

  • Collection of characters
s=str(input("Enter the name : "))
print(s)
print(type(s))

output :

Enter the name : Priya
Priya
<class 'str'>

List

  • Collection of data
l=[2,4,5,2]
print(l)
print(type(l))

output :

Tuple

  • ordered collection of data
t=(4,6,2,4)
print(t)
print(type(t))

output :


  1. Dictionary

  • An unordered collection of data has a "Key" and "Value", the key is immutable whereas the value is mutable.
l={1:'Me',2:'You',3:'Us'}
print(l)
print(type(l))

output :


  1. Set

  • The set is an unordered collection of data that is mutable, iterable and has no duplicate items.

      l={2,3,4,2,3,6,7,8,4}
      print(l)
      print(type(l))
    

output :

These are the data types ,or in-built data types of python programming.

For your reference :

DATA TYPESIMMUTABLEMUTABLE
Numeric
List
String
Dictionary
Tuple
Set

In my next blog ,you will get to know more about this data types in details.

Thank you.

More from this blog

Priya's blog

46 posts

Python Developer@Codeclause Mentee @Trailhead Salesforce Content Executive @GDSC SIT'22-23 Google Women Techmakers Ambassador @Google WTM Coreteam @ GirlScript Kolkata