Julia
% julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.5.1 (2020-08-25)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
Python
% python
Python 3.8.5 (default, Aug 5 2020, 08:22:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Get the list of all files
julia> readdir()
20-element Array{String,1}:
".dockerenv"
"bin"
"boot"
"dev"
"etc"
"home"
"lib"
"lib64"
"media"
⋮
"root"
"run"
"sbin"
"srv"
"sys"
"tmp"
"usr"
"var"
>>> import os
>>> os.listdir()
['lib', 'home', 'etc', 'media', 'var', 'srv', 'sys', 'bin', 'usr', 'root', 'boot', 'tmp', 'dev', 'opt', 'mnt', 'lib64', 'proc', 'run', 'sbin', '.dockerenv']
Join path components
julia> joinpath("/home", "file.txt")
"/home/file.txt"
>>> import os
>>> os.path.join('/home', 'file.txt')
'/home/file.txt'
Get the current working directory
>>> import os
>>> os.getcwd()
'/'
Get the running file path
Return an array of zeros with the same shape
julia> x = 1:6
1:6
julia> x = reshape(x, 2, 3)
2×3 reshape(::UnitRange{Int64}, 2, 3) with eltype Int64:
1 3 5
2 4 6
julia> zero(x)
2×3 Array{Int64,2}:
0 0 0
0 0 0
>>> import numpy as np
>>> x = np.arange(6)
>>> x = x.reshape((2, 3))
>>> x
array([[0, 1, 2],
[3, 4, 5]])
>>> np.zeros_like(x)
array([[0, 0, 0],
[0, 0, 0]])
Return an array of ones with the same shape
julia> x = 1:6
1:6
julia> x = reshape(x, 2, 3)
2×3 reshape(::UnitRange{Int64}, 2, 3) with eltype Int64:
1 3 5
2 4 6
julia> x = collect(x)
2×3 Array{Int64,2}:
1 3 5
2 4 6
julia> fill!(similar(x), 1)
2×3 Array{Int64,2}:
1 1 1
1 1 1
>>> import numpy as np
>>> x = np.arange(6)
>>> x = x.reshape((2, 3))
>>> x
array([[0, 1, 2],
[3, 4, 5]])
>>> np.ones_like(x)
array([[1, 1, 1],
[1, 1, 1]])
Get the value for the given key if key is in dictionary, and return the default value if the key is not found
julia> d = Dict("a"=>1, "b"=>2)
Dict{String,Int64} with 2 entries:
"b" => 2
"a" => 1
julia> get(d, "a", 0)
1
julia> get(d, "c", 0)
0
>>> d = {'a': 1, 'b': 2}
>>> d.get('a', 0)
1
>>> d.get('c', 0)
0