Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
423 changes: 0 additions & 423 deletions .ipynb_checkpoints/01. Getting started-checkpoint.ipynb

This file was deleted.

79 changes: 67 additions & 12 deletions 0 - Getting started.ipynb → 0 - Getting started_mod.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## How to print\n",
"\n",
Expand Down Expand Up @@ -46,12 +48,17 @@
"## How to assign variables\n",
"\n",
"All we need is a variable name, value, and an equal's sign!<br>\n",
"Julia will figure out types for us."
"Julia will figure out types for us.\n",
"There are three important types:\n",
"\n",
"1. `Int` for integer (whole number), \n",
"2. `Float` for a floating point number (e.g. 0.5, 1/3) and a \n",
"3. `String` (character string that can consist of letters, digits and/or special characters)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -60,7 +67,7 @@
"Int64"
]
},
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -91,6 +98,14 @@
"typeof(my_pi)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"64 stands for 64 bits and is the memory unit in which information is stored. In addition to Int64 and Float64, 32-bit is also common.\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
Expand Down Expand Up @@ -125,7 +140,7 @@
"metadata": {},
"outputs": [],
"source": [
"# \\:smi + <tab> --> select with down arrow + <enter> ---> <tab> + <enter> to complete"
"# \\:smi + <tab> --> complete command by writing ---> <tab> to generate Emoji"
]
},
{
Expand Down Expand Up @@ -180,6 +195,7 @@
"metadata": {},
"source": [
"Note: Julia allows us to write super generic code, and 😺 is an example of this. \n",
"Super generic codes are general and therefore reusable codes that can be applied to different data types.\n",
"\n",
"This allows us to write code like"
]
Expand Down Expand Up @@ -225,6 +241,15 @@
"😺 + 😞 == 😀"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With one equals sign = a thing is assigned to a variable.\n",
"\n",
"With two equal signs == you can check whether two things are equal. The output is either true or false. "
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -389,7 +414,7 @@
"### Exercises\n",
"\n",
"#### 1.1 \n",
"Look up docs for the `convert` function."
"Look up documentations for the `convert` function with `help?>`"
]
},
{
Expand All @@ -416,7 +441,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"deletable": false,
"editable": false,
Expand All @@ -431,7 +456,20 @@
"solution": false
}
},
"outputs": [],
"outputs": [
{
"ename": "LoadError",
"evalue": "UndefVarError: `days` not defined",
"output_type": "error",
"traceback": [
"UndefVarError: `days` not defined",
"",
"Stacktrace:",
" [1] top-level scope",
" @ In[4]:1"
]
}
],
"source": [
"@assert days == 365\n",
"@assert days_float == 365.0\n"
Expand All @@ -446,12 +484,29 @@
"\n",
"```julia\n",
"convert(Int64, \"1\")\n",
"\n",
"```\n",
"\n",
"and\n",
"\n",
"```julia\n",
"parse(Int64, \"1\")\n",
"```"
"\n",
"```\n",
"\n",
"<details>\n",
" <summary> unfold result</summary>\n",
"The convert function can be used, for example, to convert a float into an integer, or vice versa.\n",
" \n",
" \n",
" \n",
"-> convert(type, number)\n",
" \n",
"The parse function splits a string into an integer or a float\n",
"\n",
"-> parse(type, \"string\")\n",
"\n",
"</details>\n"
]
},
{
Expand All @@ -464,15 +519,15 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.6.0",
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.6"
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.6.3"
"version": "1.10.2"
}
},
"nbformat": 4,
Expand Down
64 changes: 39 additions & 25 deletions 1 - Strings.ipynb → 1 - Strings_mod.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"source": [
"## How to get a string\n",
"\n",
"Enclose your characters in \" \" or \"\"\" \"\"\"!"
"Enclose your strings in \" \" or \"\"\" \"\"\"!"
]
},
{
Expand Down Expand Up @@ -119,7 +119,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that ' ' define a character, but NOT a string!"
"Note that ' ' define a character, but NOT a string!\n",
"\n",
"A character is a single character and can be converted into a numerical value.\n",
"Char = character and the char() function converts an integer back into a character"
]
},
{
Expand Down Expand Up @@ -173,6 +176,7 @@
"metadata": {},
"source": [
"## String interpolation\n",
"An interpolation is a later insertion or change in a text that is not marked as one.\n",
"\n",
"We can use the $ sign to insert existing variables into a string and to evaluate expressions within a string. <br>\n",
"Below is an example that contains some highly sensitive personal information."
Expand Down Expand Up @@ -242,31 +246,20 @@
"source": [
"## String concatenation\n",
"\n",
"Below are three ways we can concatenate strings! <br><br>\n",
"Below are two ways we can concatenate strings! <br><br>\n",
"The first way is to use the `string()` function. <br>\n",
"`string()` converts non-string inputs to strings."
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"s3 = \"How many cats \";\n",
"s4 = \"is too many cats?\";\n",
"😺 = 10"
"s3 =\"How many cats\"\n",
"s4 = \"is too many cats?\"\n",
"😸 = 10"
]
},
{
Expand All @@ -289,6 +282,15 @@
"string(s3, s4)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Or:"
]
},
{
"cell_type": "code",
"execution_count": 12,
Expand All @@ -306,14 +308,15 @@
}
],
"source": [
"string(\"I don't know, but \", 😺, \" is too few.\")"
"string(\"I don't know, but \", 😸, \" is too few.\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also use `*` for concatenation!"
"\n",
"And secondly we can also use `*` for concatenation!"
]
},
{
Expand Down Expand Up @@ -343,7 +346,18 @@
"### Exercises\n",
"\n",
"#### 2.1 \n",
"Create a string that says \"hi\" 1000 times, first with `repeat` and then with the exponentiation operator, which can call `*` under the hood. Assign it the variable `hi` below."
"Create a string that says \"hi\" 1000 times, first with `repeat` and then with the exponentiation operator `^`. \n",
"\n",
"Assign it the variable `hi` below.\n",
"\n",
"<details>\n",
" <summary> Tip</summary>\n",
"\n",
"for example 2^4 can also be written as 2 * 2 * 2 * 2, and therefore strings can be concatenated with the exponential operator. \n",
" \n",
"repeat(\"string\" or 'character', number of repetitions)\n",
"\n",
"\n"
]
},
{
Expand Down Expand Up @@ -447,15 +461,15 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.6.0",
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.6"
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.6.3"
"version": "1.10.2"
}
},
"nbformat": 4,
Expand Down
File renamed without changes.
Loading