[ADD] Finished week 1

This commit is contained in:
Eduardo Cueto Mendoza 2020-05-16 22:38:06 -06:00
parent 4cf86c9f09
commit 358f667e54
6 changed files with 3023 additions and 0 deletions

164
01_Coursera_1.ipynb Normal file
View File

@ -0,0 +1,164 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello World!\n"
]
}
],
"source": [
"println(\"Hello World!\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"14"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"5+9 # 14"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello! My word! Hello! My word! \n"
]
}
],
"source": [
"println((\"Hello!\" * \" My word! \")^2)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"search: \u001b[0m\u001b[1mp\u001b[22m\u001b[0m\u001b[1mr\u001b[22m\u001b[0m\u001b[1mi\u001b[22m\u001b[0m\u001b[1mn\u001b[22m\u001b[0m\u001b[1mt\u001b[22m\u001b[0m\u001b[1ml\u001b[22m\u001b[0m\u001b[1mn\u001b[22m \u001b[0m\u001b[1mp\u001b[22m\u001b[0m\u001b[1mr\u001b[22m\u001b[0m\u001b[1mi\u001b[22m\u001b[0m\u001b[1mn\u001b[22m\u001b[0m\u001b[1mt\u001b[22msty\u001b[0m\u001b[1ml\u001b[22med \u001b[0m\u001b[1mp\u001b[22m\u001b[0m\u001b[1mr\u001b[22m\u001b[0m\u001b[1mi\u001b[22m\u001b[0m\u001b[1mn\u001b[22m\u001b[0m\u001b[1mt\u001b[22m s\u001b[0m\u001b[1mp\u001b[22m\u001b[0m\u001b[1mr\u001b[22m\u001b[0m\u001b[1mi\u001b[22m\u001b[0m\u001b[1mn\u001b[22m\u001b[0m\u001b[1mt\u001b[22m is\u001b[0m\u001b[1mp\u001b[22m\u001b[0m\u001b[1mr\u001b[22m\u001b[0m\u001b[1mi\u001b[22m\u001b[0m\u001b[1mn\u001b[22m\u001b[0m\u001b[1mt\u001b[22m\n",
"\n"
]
},
{
"data": {
"text/latex": [
"\\begin{verbatim}\n",
"println([io::IO], xs...)\n",
"\\end{verbatim}\n",
"Print (using \\href{@ref}{\\texttt{print}}) \\texttt{xs} followed by a newline. If \\texttt{io} is not supplied, prints to \\href{@ref}{\\texttt{stdout}}.\n",
"\n",
"\\section{Examples}\n",
"\\begin{verbatim}\n",
"julia> println(\"Hello, world\")\n",
"Hello, world\n",
"\n",
"julia> io = IOBuffer();\n",
"\n",
"julia> println(io, \"Hello, world\")\n",
"\n",
"julia> String(take!(io))\n",
"\"Hello, world\\n\"\n",
"\\end{verbatim}\n"
],
"text/markdown": [
"```\n",
"println([io::IO], xs...)\n",
"```\n",
"\n",
"Print (using [`print`](@ref)) `xs` followed by a newline. If `io` is not supplied, prints to [`stdout`](@ref).\n",
"\n",
"# Examples\n",
"\n",
"```jldoctest\n",
"julia> println(\"Hello, world\")\n",
"Hello, world\n",
"\n",
"julia> io = IOBuffer();\n",
"\n",
"julia> println(io, \"Hello, world\")\n",
"\n",
"julia> String(take!(io))\n",
"\"Hello, world\\n\"\n",
"```\n"
],
"text/plain": [
"\u001b[36m println([io::IO], xs...)\u001b[39m\n",
"\n",
" Print (using \u001b[36mprint\u001b[39m) \u001b[36mxs\u001b[39m followed by a newline. If \u001b[36mio\u001b[39m is not supplied, prints\n",
" to \u001b[36mstdout\u001b[39m.\n",
"\n",
"\u001b[1m Examples\u001b[22m\n",
"\u001b[1m ≡≡≡≡≡≡≡≡≡≡\u001b[22m\n",
"\n",
"\u001b[36m julia> println(\"Hello, world\")\u001b[39m\n",
"\u001b[36m Hello, world\u001b[39m\n",
"\u001b[36m \u001b[39m\n",
"\u001b[36m julia> io = IOBuffer();\u001b[39m\n",
"\u001b[36m \u001b[39m\n",
"\u001b[36m julia> println(io, \"Hello, world\")\u001b[39m\n",
"\u001b[36m \u001b[39m\n",
"\u001b[36m julia> String(take!(io))\u001b[39m\n",
"\u001b[36m \"Hello, world\\n\"\u001b[39m"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"?println"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.2.0",
"language": "julia",
"name": "julia-1.2"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.2.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

26
01_Coursera_2.ipynb Normal file
View File

@ -0,0 +1,26 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.2.0",
"language": "julia",
"name": "julia-1.2"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.2.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

406
02_Coursera_1.ipynb Normal file
View File

@ -0,0 +1,406 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-2"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1-2+3-4"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5//4"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1//2+3//4"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.05"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1/(2+3)/4"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4//11"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1//(2+(3//4))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"7//8"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(1//2+3)//4"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"!true"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"!false"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"true && true"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"true && false"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"false || true"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"84.0"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"5040 / 60"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"11"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"8+2*3-3"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2^2+6"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"0-6+2^4"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"9"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2*3+2^1+1"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1+3<5||2+2<1"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"3 & 5 > 0 "
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"8 & 5 > 0"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1 + (2 - 5) - 2 == 0"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.2.0",
"language": "julia",
"name": "julia-1.2"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.2.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

820
03_Coursera_1.ipynb Normal file
View File

@ -0,0 +1,820 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"8"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"length(bitstring(parse(Int8,\"4\")))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"8"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"length(bitstring(Int8(4)))"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Int8"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"typeof(Int8(3))"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"11001110101100010000000000000000\""
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bitstring('α')"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2-element Array{Int64,1}:\n",
" 0\n",
" 1"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"digits(10, base = 10)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4-element Array{Int64,1}:\n",
" 0\n",
" 1\n",
" 0\n",
" 1"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"digits(10, base = 2)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"typeof(2) == typeof(4.0)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{Int64,1}:\n",
" 4695258384\n",
" 4695258416\n",
" 4695258448"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Array{Int64}(undef,3)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{String,1}:\n",
" #undef\n",
" #undef\n",
" #undef"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Array{String}(undef,3)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"Hello World!\""
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"greeting = \"Hello World!\""
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello World!\n"
]
}
],
"source": [
"println(greeting)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{Int64,1}:\n",
" 1\n",
" 2\n",
" 3"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = [1,2,3]"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{Int64,1}:\n",
" 1\n",
" 2\n",
" 3"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b = a"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b[2] = 5"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{Int64,1}:\n",
" 1\n",
" 5\n",
" 3"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"7"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a[1] = 7"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{Int64,1}:\n",
" 7\n",
" 5\n",
" 3"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{Int64,1}:\n",
" 7\n",
" 5\n",
" 3"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c = a[:]"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"9"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a[3] = 9"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{Int64,1}:\n",
" 7\n",
" 5\n",
" 3"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{Int64,1}:\n",
" 7\n",
" 5\n",
" 9"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2×3 Array{Integer,2}:\n",
" #undef #undef #undef\n",
" #undef #undef #undef"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"abstypevariable = Array{Integer}(undef,2,3)"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Array{Integer,2}"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"typeof(abstypevariable)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"ename": "UndefRefError",
"evalue": "UndefRefError: access to undefined reference",
"output_type": "error",
"traceback": [
"UndefRefError: access to undefined reference",
"",
"Stacktrace:",
" [1] getindex(::Array{Integer,2}, ::Int64, ::Int64) at ./array.jl:729",
" [2] top-level scope at In[35]:1"
]
}
],
"source": [
"abstypevariable[2,1]"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"6"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"length(abstypevariable)"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(2, 3)"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"size(abstypevariable)"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(3,)"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"size([1,2,3])"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"abstypevariable[1,1] = 1"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5.0"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"abstypevariable[1,2] = 5.0 #5.3 not possible"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2×3 Array{Integer,2}:\n",
" 1 5 #undef\n",
" #undef #undef #undef"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"abstypevariable"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"ename": "MethodError",
"evalue": "MethodError: Cannot `convert` an object of type String to an object of type Integer\nClosest candidates are:\n convert(::Type{T<:Number}, !Matched::T<:Number) where T<:Number at number.jl:6\n convert(::Type{T<:Number}, !Matched::Number) where T<:Number at number.jl:7\n convert(::Type{T<:Integer}, !Matched::Ptr) where T<:Integer at pointer.jl:23\n ...",
"output_type": "error",
"traceback": [
"MethodError: Cannot `convert` an object of type String to an object of type Integer\nClosest candidates are:\n convert(::Type{T<:Number}, !Matched::T<:Number) where T<:Number at number.jl:6\n convert(::Type{T<:Number}, !Matched::Number) where T<:Number at number.jl:7\n convert(::Type{T<:Integer}, !Matched::Ptr) where T<:Integer at pointer.jl:23\n ...",
"",
"Stacktrace:",
" [1] setindex!(::Array{Integer,2}, ::String, ::Int64, ::Int64) at ./array.jl:768",
" [2] top-level scope at In[46]:1"
]
}
],
"source": [
"abstypevariable[2,2] = \"stringystringstr\""
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2×3 Array{Int64,2}:\n",
" 4679027904 4583513520 -1\n",
" 4661545168 1 4311744769"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"arbconcretevariable = Array{Int64}(undef,2,3)"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'c': ASCII/Unicode U+0063 (category Ll: Letter, lowercase)"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Cake = 'c'"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"'a' === \"a\""
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3×2 Array{Integer,2}:\n",
" #undef #undef\n",
" #undef #undef\n",
" #undef #undef"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = Array{Integer,2}(undef, 3, 2)"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"11×12 Array{Int64,2}:\n",
" 4684904288 4671225872 4671226928 … 4671236288 4671236816 4671237344\n",
" 4684904336 4671225920 4671226976 4671236336 4671236864 4671237392\n",
" 4684904384 4671225968 4671227024 4671236384 4671236912 4671237440\n",
" 4684904432 4671226016 4671227504 4671236432 4671236960 4671237488\n",
" 4684904480 4671226064 4671227552 4671236480 4671237008 4671237536\n",
" 4684904528 4671226112 4671227600 … 4671236528 4671237056 4671237584\n",
" 4684904576 4671226160 4671227984 4671236576 4671237104 4671237680\n",
" 4684904624 4671226208 4671228032 4671236624 4671237152 4671237728\n",
" 4684904672 4671226448 4671228080 4671236672 4671237200 4671237776\n",
" 4684904720 4671226496 4671228464 4671236720 4671237248 4671237824\n",
" 4671176608 4671226544 4671228656 … 4671236768 4671237296 4671238352"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = Array{Int64}(undef,11, 12) \n"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Array{Int64,2}"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"typeof(x)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.2.0",
"language": "julia",
"name": "julia-1.2"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.2.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

1102
04_Coursera_1.ipynb Normal file

File diff suppressed because it is too large Load Diff

505
05_Coursera_1.ipynb Normal file
View File

@ -0,0 +1,505 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"36"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"3^2^1^5+3^3"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Int64"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"typeof(3^2^1^5+3^3)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"36\n"
]
}
],
"source": [
"println(\"$(6*6)\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"36\n"
]
},
{
"data": {
"text/plain": [
"Nothing"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"typeof(println(\"$(6*6)\"))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"240"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2^2^3-2^4"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"48"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(2^2)^3-2^4"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(5 - 7) * 2 + 4"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1 + 3 < 5 && 2^2 === 4.0"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2^2 === 4.0"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = 4\n",
"\n",
"x > 0 && x <= 3"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"((true && false) && false) || true"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(true && false) && (false || true)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"true && ((false && false) || true)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"15×2 Array{Float64,2}:\n",
" 1.68005 -1.6417 \n",
" 0.501309 -0.977698\n",
" 1.52801 0.527711\n",
" 1.70012 1.71152 \n",
" 1.99249 1.891 \n",
" 2.70608 -0.463428\n",
" 2.99493 -0.443567\n",
" 3.49185 -1.27518 \n",
" 3.50119 -0.6905 \n",
" 4.45992 -5.51613 \n",
" 4.93697 -6.0017 \n",
" 5.02329 -8.36417 \n",
" 5.04234 -7.92448 \n",
" 5.50739 -10.7748 \n",
" 5.56867 -10.9172 "
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = [1.6800483 -1.641695388; \n",
" 0.501309281 -0.977697538; \n",
" 1.528012113 0.52771122;\n",
" 1.70012253 1.711524991; \n",
" 1.992493625 1.891000015;\n",
" 2.706075824 -0.463427794;\n",
" 2.994931927 -0.443566619;\n",
" 3.491852811 -1.275179133;\n",
" 3.501191722 -0.690499597;\n",
" 4.459924502 -5.516130799;\n",
" 4.936965851 -6.001703074;\n",
" 5.023289852 -8.36416901;\n",
" 5.04233698 -7.924477517;\n",
" 5.50739285 -10.77482371;\n",
" 5.568665171 -10.9171878]"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"15-element Array{Float64,1}:\n",
" 1.6800483 \n",
" 0.501309281\n",
" 1.528012113\n",
" 1.70012253 \n",
" 1.992493625\n",
" 2.706075824\n",
" 2.994931927\n",
" 3.491852811\n",
" 3.501191722\n",
" 4.459924502\n",
" 4.936965851\n",
" 5.023289852\n",
" 5.04233698 \n",
" 5.50739285 \n",
" 5.568665171"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data[:,1]"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"coordinates (generic function with 1 method)"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function coordinates(x, y, z)\n",
" if x==0 && z == 0 && y==0\n",
" println(\"origin\")\n",
" else\n",
" println(\"($x, $y, $z)\")\n",
" end\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(0, 0, 2)\n"
]
}
],
"source": [
"coordinates(0,0,2)"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"origin\n"
]
}
],
"source": [
"coordinates(0,0,0)"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(19, 3)"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a, b = 2, 3 \n",
"function f(x) \n",
" b = 5 \n",
" a*x + b\n",
"end\n",
"f(7), b"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"f (generic function with 1 method)"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function f(x)\n",
" return 2x\n",
" 3x\n",
" print(\"5\")\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f(5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.2.0",
"language": "julia",
"name": "julia-1.2"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.2.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}