Declaring Variables: Integers, float and string in Python.
In this post we will how to declare different type of variables in python.
Using Numbers: Integers and float & Strings in Python
Lets have a look how to use integers, float and strings in python.
user@ngelinux$ cat fourth.py #!/usr/bin/python ### Declaring and printing a integer variable intvar=5 print(intvar) ### Declaring and printing a float variable floatvar=5.199 print(floatvar) ### Using Strings stringvar="hello" print(stringvar) #### Another way to define variable type specifically #### making intvar to float intvar2=float(5) print(intvar2)
Output
Now lets run above program and see the variables got printed.
It means there is no need to declare variables’ type in python.
It is automatically taken by the interpreter.
user@ngelinux$ ./fourth.py 5 5.199 hello 5.0 user@ngelinux$