Variable is
a named memory location that points to a value.
julia> firstName="Hari Krishna" "Hari Krishna" julia> lastName="Gurram" "Gurram" julia> age=27 27
Observe above code snippet, it define
three variables firstName, lastName and age. Variable firstName, lastName are
of type string and age of type integer.
julia> typeof(firstName) ASCIIString julia> typeof(lastName) ASCIIString julia> typeof(age) Int64
Since Julia is a dynamic language, you
can assign any type of value to a variable.
julia> x=10 10 julia> typeof(x) Int64 julia> x=10.234 10.234 julia> typeof(x) Float64 julia> x=true true julia> typeof(x) Bool julia> x="Krishna" "Krishna" julia> typeof(x) ASCIIString
Variable
names are case sensitive, i.e, myName, MyName, myname are three different
variables.
julia> myName="Krishna" "Krishna" julia> myname="hari" "hari" julia> MyName="gopi" "gopi" julia> myName "Krishna" julia> MyName "gopi" julia> myname "hari"
You can construct a variable name using any
Unicode characters.
julia> 名称="Hari Krishna" "Hari Krishna" julia> 年龄=27 27 julia> 名称 "Hari Krishna" julia> 年龄 27
Naming
conventions for a variable
a. Variable name must begin with a
character a-z, A-Z, _(underscore) (or) a subset of Unicode code points greater
than 00A0.
b. Subsequent characters (after first
character) include ! and digits 0-9.
c. Variable names are in lower case as per
convetion.
d. Separate long variable names with
underscore(_) like my_name, my_age, my_salary.
No comments:
Post a Comment