Home‎ > ‎Python‎ > ‎

Variables


Define variable type

Strings

you can define a variable to be just a string. 
Code: 
greetings = "hello world"
print("string output = " + str(greetings))
Output: 
string output = hello world

Integers and Floats: 

Integers are normal numbers, floats include a decimal point.  

Code:
n = 9
print("integer = ", int(n)) # print type of variable "number"

float_number = 9
print("float number = ",float(float_number))
Output: 
integer =  9
float number =  9.0




Comments