We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5
Built in Data Types
and Type Casting
Data Types in Python ● Python has three main Data Types:- ○ Integer ○ Float ○ String ● Data type is an attribute of data which tells us what kind of data that value can have. ● x = 4, Here x is an integer data type
● y = ‘India’, Here y is a string data type
Ninja Trick
● A function is a block of organized, reusable code that is used to perform a single,
related action. ● Python uses a built-in function called type() which gives the data type of a variable without printing the actual variable. X=4 print(type(x)) ➔ X is an integer type Jargon Alert: TypeCasting
● TypeCasting refers to changing the data type of a variable from one form to another.
● There are three Type casting functions in Python:
○ Int() ○ float() ○ str(). TypeCasting Examples
● int(): Used to convert a string or float value to integer.
○ X = int(5), Integer 5 is assigned to X. ● float(): Used to convert an integer or string value to float. ○ Y = int(6.7), 6.7 is converted to integer 6 and assigned to Y. ● str(): Used to convert an integer or float value to string. ○ Z = int(“2”), string is converted to integer 2 assigned to Z.