Day 3: Some basic data types in Python

The most basic data types with python includes Strings, numbers, boolean and floats.

Integers are for whole numbers only, signed or unsigned. It does not contain any decimal value.

Eg. 10, 12, 3345, 0, 34_405_000

Point to note: Integers cannot start with 0

>>> 05
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers

Floats contain decimals, signed or unsigned.

Eg. -55.23, 23.345, 0.0, .56, 0.7345, 1.23345e10, 1_000e234, 4.5e-3

Like javascript’s typeof operator, python has a similar type in-built function to ascertain data types.

>>> type(2334)
<class 'int'>

>>> type(23.34)
<class 'float'>

>>> type(1_000)
<class 'int'>

>>> type(1_000e234)
<class 'float'>

Floating point precision in Python

>>> 5.77777777777777777777777777
5.777777777777778

This concludes for today!

What’s your Reaction?
+1
0
+1
0
+1
0

Published by Soumil Roy

I'm a Full-Stack Developer with 7+ years of experience in Web design & development .Currently building expertise in React, TypeScript & GraphQL

Leave a comment

Your email address will not be published.

Open WhatApp
Hello 👋 Click the button below connect with me.