[PYTHON] Julia Quick Note [01] How to use variables and constants

How to use variables and constants (example of how to write)

note01


◆ Variable declaration

integer
  x = 1
  y = -100

Real number
  a = 2.0
  b = 3.14
  c = -5.0

◆ Declaration of constants
 const t = 2020

◆ Character expression
 x = 2
 y = 2x + 1
 h = sin(pi / 2)

Commentary

In Julia, like JavaScript and Python, it is not necessary to specify the type of the variable (actually, it has the type internally). You can set the value intuitively.

(1) Addition, subtraction, multiplication of integers

The calculation result is also an integer. image.png

(2) Division between integers

The calculation result is a real number for both divisible and indivisible numbers. image.png

(3) Calculation of mixed integers and real numbers

The calculation result is a real number. image.png

(4) Handling of constants

Constants are declared as const. image.png If you change it later, an error will occur. image.png

(5) About character expressions

You can treat variables like mathematical expressions. image.png You can also use mathematical arithmetic functions. image.png The "$ \ pi $" and "e" used above are the following mathematical constants, respectively.

letter Meaning and usage
\pi Pi. On the keyboard\Enter "pi" and press the tab key.
e Napier number(Natural logarithm).. On the keyboard\Enter "euler" and press the tab key.

There are many other mathematical formulas. Please refer to the official document below for details.

:paperclip: Julia - Mathematics https://docs.julialang.org/en/v1/base/math/

(6) About reserved variable names

In Julia, there are the following reserved words. You cannot use these as variable names on your own.

baremodule, begin, break, catch, const, continue, do, else, elseif, end, export, false, finally, for, function, global, if, import, let, local, macro, module, quote, return, struct, true, try, using, while

Please refer to the official document below for details.

:paperclip: Julia - Keywords https://docs.julialang.org/en/v1/base/base/#Keywords

Lottery

Julia Quick Look Note [01] How to use variables and constants

(* We will continue to increase the content)

Related information

: paperclip: Julia --Official page https://julialang.org/

: paperclip: Julia --Japanese official document https://julia-doc-ja.readthedocs.io/ja/latest/index.html

: paperclip: First time Julia and installation (Windows & Linux) https://qiita.com/ttlabo/items/b05bb43d06239f968035

:paperclip: Julia - Mathematics https://docs.julialang.org/en/v1/base/math/

Opinions etc.

If you have any opinions or corrections, please let us know.

Recommended Posts

Julia Quick Note [01] How to use variables and constants
[Note] How to use virtualenv
How to install and use Tesseract-OCR
How to use .bash_profile and .bashrc
How to install and use Graphviz
How to install and use pandas_datareader [Python]
How to use Serverless Framework & Python environment variables and manage stages
How to use Python zip and enumerate
How to use is and == in Python
How to use pandas Timestamp and date_range
How to use lists, tuples, dictionaries, and sets
Introducing Sinatra-style frameworks and how to use them
How to create explanatory variables and objective functions
How to use pip3 under proxy environment Note
[Python] How to use hash function and tuple.
How to install Cascade detector and how to use it
How to use xml.etree.ElementTree
How to use Python-shell
How to use tf.data
How to use virtualenv
How to use Seaboan
How to use image-match
How to use shogun
How to use Virtualenv
How to use numpy.vectorize
How to use pytest_report_header
How to use partial
How to use Bio.Phylo
How to use SymPy
How to use x-means
How to use WikiExtractor.py
How to use virtualenv
How to use Matplotlib
How to use iptables
How to use numpy
How to use TokyoTechFes2015
How to use venv
How to use dictionary {}
How to use Pyenv
How to use list []
How to use python-kabusapi
How to use OptParse
How to use return
How to use dotenv
How to use pyenv-virtualenv
How to use Go.mod
How to use imutils
How to use import
Beginners! Basic Linux commands and how to use them!
How to use the grep command and frequent samples
How to use variables in systemd Unit definition files
How to use argparse and the difference between optparse
How to use Decorator in Django and how to make it
How to use Qt Designer
How to use search sorted
Julia Quick Note [03] Complex Numbers
python3: How to use bottle (2)
Understand how to use django-filter
Julia Quick Note [06] Loop processing
How to use the generator
Julia Quick Note [10] Function (2) Application