18
Data Types in python
In my last post we came across the string.
Print() built in function in python
well,i haven't said any thing about,what is string.
So,this is all bout it
The string comes under DataTypes.
what Exactly are DataTypes?
=>DataTypes - are used to classify one particular type of data.
This is important because the specific data type you use will determine what values you can assign to Variable and what you can do to it.
Data types are important in web applications or software or programs in many sense.
Data types gives meaning to data.
So,thats said
There are different DataTypes
1.Integer-int
2.String -str
3.Float -float
4.Boolean-True,False
Indetail
This Integer is denoted by keyword:'int'
this is used to define the variable it is an integer.
as we know integers are-0,1,2,3,4.......... and even -ve numbers.
The range of this int is from -2,147,483,647 to 2,147,483,647 for 9 or 10 digits of precision.
The int can be defined as
x=12
here we are using variable x the store the DataType-int
to know the datatype of the variable-x we can use the 'type()' built in function
if we are using a large number we can split by using an Underscore(_),ie.123_456_789
this underscore doesn't change the value of the number,it is taken
as 123456789.
this string is denoted by keyword:'str'
This string is group of characters,the characters in the sence a,v,e,r,o,e,y,1,3,54..... what ever the keys that are in keyboard.
But,This string must be denoted in Double Quotations
like :
x="Hola"
x="12345"
x="/'.;p]["
And we can also check the type by using type() built in function to see what DataType it is,
if we want to print the str multiple time,we cant just write print() so many time
coz it sucks and wast of time.that dosent make us much of a programmer if we cant minimize the size and time.
As time and size are very crucial in programming.
So,is there a way to do that ?
yes,there is way we can print multiple times by using \n at the end of the string
it is done like :
we can add two str we use + sign this is known as String Concatenation
f-String
Some times in during printing the result we want to specify the result in the string in print().
But,it is not possible to print both string and result(as it might be other DataTypes-int,float,boolean)
so to make that happen we need to use this f-String
we can do it like:
In this string wecan specify the certain character if we need to it canbe done by using[] to specify the index of the character.
like:
so now next to
Now The Last One
If there are any Suggestions Or corrections fell free to say
Print("Thank YOu!")
18