Skip to content

Commit

Permalink
lecture 3
Browse files Browse the repository at this point in the history
  • Loading branch information
yoninazarathy committed Jul 23, 2024
1 parent 0dff44a commit 6391b19
Showing 1 changed file with 202 additions and 0 deletions.
202 changes: 202 additions & 0 deletions lecture-and-consult-scraps/Lecture3.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 10,
"id": "fa984d8b-fbf3-4f4f-bbd2-f68e816c8080",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"11"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = 10\n",
"# x++\n",
"x += 1"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "25f039c0-7041-43f3-9f34-8cd62f58b108",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The total is: 55\n",
"And using a formula: 55\n"
]
}
],
"source": [
"total = 0\n",
"max_val = 10\n",
"for i ∈ 1:max_val \n",
" # total = total + i\n",
" total += i #this is exactly like the commented line above\n",
"end\n",
"println(\"The total is: $total\")\n",
"println(\"And using a formula: \", max_val*(max_val+1) ÷ 2)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "33309821-629e-4f6b-a1e0-61e5a13cae49",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2.0"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"4/2"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "17280378-8c29-4b97-b540-355e27276147",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2//1"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"4//2 #In python this would be \"integer division\" in Julia it is a rational type"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "e2ff7d62-80ab-46e3-a254-591907c90d5e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Rational{Int64}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"typeof(4//2)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "f7ca1137-398c-4f32-a9b8-c53a70bb198f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"4 ÷ 2 # \\div + [TAB] "
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "60501767-f8e8-4eea-8da4-7017adf7d182",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"div(4,2)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "47fd8035-1422-4606-b04e-7e7823690ddb",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"5 ÷ 2"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e3a57882-bec9-42d1-aed1-e596d775bc81",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.10.4",
"language": "julia",
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 6391b19

Please sign in to comment.