On Variables and Operators
On Variables and Operators
>>> 0
0
>>> 100
100
>>> -10
-10
>>> 1234567890
1234567890
>>> y=5000000000000000000000000000000000000000000000000000000
5000000000000000000000000000000000000000000000000000000
2.Float:
The float type in Python represents the floating point number. Float is
used to represent real numbers and is written with a decimal point
dividing the integer and fractional parts. For example, 97.98, 32.3+e18,
-32.54e100 all are floating point numbers.
Example: float()
print("int to float: ", float(10))
print("int to float: ", float(-10))
print("string to float: ", float('10.2’))
print("string to float: ", float('-10.2'))
Output:
int to float: 10.0
int to float: -10.0
string to float: 10.2
string to float: -10.2
3.String:
Input:
1.str1 = 'Hello Python'
2.print(str1)
Using double quotes
3.str2 = "Hello Python"
4.print(str2)
Output:
Hello Python
Hello Python
Hello Python Hello Python
Rules:
• A variable name must start with a letter or the
underscore character.