Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ITGK 2020 Øvinger
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joakim Ness
ITGK 2020 Øvinger
Commits
30fc32f5
Commit
30fc32f5
authored
4 years ago
by
Aubert
Browse files
Options
Downloads
Patches
Plain Diff
legg til LF for OF1
parent
46a21571
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Ovingsforelesninger/sindre/lecture1.ipynb
+3
-3
3 additions, 3 deletions
Ovingsforelesninger/sindre/lecture1.ipynb
Ovingsforelesninger/sindre/lecture1_lf.ipynb
+254
-0
254 additions, 0 deletions
Ovingsforelesninger/sindre/lecture1_lf.ipynb
with
257 additions
and
3 deletions
Ovingsforelesninger/sindre/lecture1.ipynb
+
3
−
3
View file @
30fc32f5
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
"cell_type": "markdown",
"cell_type": "markdown",
"metadata": {},
"metadata": {},
"source": [
"source": [
"# Øvingsforelesning 1 - Parallel 1"
"# Øvingsforelesning 1 -
TDT4110
Parallel
l
1"
]
]
},
},
{
{
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
3
,
"execution_count":
1
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -181,4 +181,4 @@
...
@@ -181,4 +181,4 @@
},
},
"nbformat": 4,
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 2
}
}
\ No newline at end of file
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# Øvingsforelesning 1 - Parallel 1
# Øvingsforelesning 1 -
TDT4110
Parallel
l
1
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
**Læremål**
:
**Læremål**
:
*
Bli introdusert til hva programmering er
*
Bli introdusert til hva programmering er
*
Grunnleggende syntaks
*
Grunnleggende syntaks
*
Utføre enkle utregninger i Python
*
Utføre enkle utregninger i Python
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## Oppgave 1
## Oppgave 1
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
**Regn ut følgende i Python ved hjelp av kode**
**Regn ut følgende i Python ved hjelp av kode**


%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
# Skriv regnestykke 1 her
# Skriv regnestykke 1 her
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
# Skriv regnestykke 2 her
# Skriv regnestykke 2 her
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
# Skriv regnestykke 3 her
# Skriv regnestykke 3 her
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
# Skriv regnestykke 4 her
# Skriv regnestykke 4 her
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## Oppgave 2
## Oppgave 2
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
**Hva tilsvarer 80 grader celsius i Fahrenheit?**
**Hva tilsvarer 80 grader celsius i Fahrenheit?**
$$F =
\f
rac{9}{5}Celsius + 32$$
$$F =
\f
rac{9}{5}Celsius + 32$$
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
# Skriv koden din her
# Skriv koden din her
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## Oppgave 3
## Oppgave 3
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
**Hva returneres ved å regne ut følgende uttrykk i Python?**
$$
\f
rac{7!}{5!-3}$$
**Hva returneres ved å regne ut følgende uttrykk i Python?**
$$
\f
rac{7!}{5!-3}$$
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
*Merk at 7! er fakultetet av 7 og kan skrives som $ 7! = 7*
6
*5*
4
*3*
2
*1$*
*Merk at 7! er fakultetet av 7 og kan skrives som $ 7! = 7*
6
*5*
4
*3*
2
*1$*
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
# Skriv koden din her
# Skriv koden din her
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## Oppgave 4
## Oppgave 4
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
**Er 1000 000 000 større enn $2^{30}$?**
**Er 1000 000 000 større enn $2^{30}$?**
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
# Skriv koden din her
# Skriv koden din her
```
```
...
...
This diff is collapsed.
Click to expand it.
Ovingsforelesninger/sindre/lecture1_lf.ipynb
0 → 100644
+
254
−
0
View file @
30fc32f5
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Øvingsforelesning 1 Løsningsforslag- TDT4110 Parallell 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Læremål**:\n",
"\n",
"* Bli introdusert til hva programmering er\n",
"\n",
"* Grunnleggende syntaks\n",
"\n",
"* Utføre enkle utregninger i Python\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Oppgave 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Regn ut følgende i Python ved hjelp av kode**\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": "-5"
},
"metadata": {},
"execution_count": 5
}
],
"source": [
"print(4*-2-(2+-5))"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": "-2"
},
"metadata": {},
"execution_count": 2
}
],
"source": [
"print(-2--2-2)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": "3"
},
"metadata": {},
"execution_count": 4
}
],
"source": [
"print(5-2**(-1*-1))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": "240"
},
"metadata": {},
"execution_count": 6
}
],
"source": [
"print(-(1*1*2*3*5*-8))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Oppgave 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Hva tilsvarer 80 grader celsius i Fahrenheit?**\n",
"$$F = \\frac{9}{5}Celsius + 32$$"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": true,
"tags": []
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "176.0\n176.0\n80 grader celcius tilsvarer 176.0 grader fahrenheit\n"
}
],
"source": [
"#Rett frem\n",
"print(9/5*80+32)\n",
"\n",
"#Ved hjelp av variabel\n",
"degrees_celcius = 80\n",
"F = (9/5)*degrees_celcius + 32\n",
"print(F)\n",
"\n",
"#Bonus: Omregningen kan også skrives ut som en setning\n",
"print(f'{degrees_celcius} grader celcius tilsvarer {F} grader fahrenheit')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Oppgave 3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Hva returneres ved å regne ut følgende uttrykk i Python?** $$\\frac{7!}{5!-3}$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Merk at 7! er fakultetet av 7 og kan skrives som $ 7! = 7*6*5*4*3*2*1$*"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": true,
"tags": []
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "43.07692307692308\n43.07692307692308\n"
}
],
"source": [
"# Rett frem\n",
"print((7*6*5*4*3*2*1)/((5*4*3*2*1)-3))\n",
"\n",
"# Bonus: ved hjelp av math-modulen\n",
"import math\n",
"print(math.factorial(7)/(math.factorial(5)-3))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Oppgave 4 "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Er 1000 000 000 større enn $2^{30}$?**"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"tags": []
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "False\n"
}
],
"source": [
"print(1000000000 > 2**30)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
\ No newline at end of file
%% Cell type:markdown id: tags:
# Øvingsforelesning 1 Løsningsforslag- TDT4110 Parallell 1
%% Cell type:markdown id: tags:
**Læremål**
:
*
Bli introdusert til hva programmering er
*
Grunnleggende syntaks
*
Utføre enkle utregninger i Python
%% Cell type:markdown id: tags:
## Oppgave 1
%% Cell type:markdown id: tags:
**Regn ut følgende i Python ved hjelp av kode**

%% Cell type:code id: tags:
```
python
print
(
4
*-
2
-
(
2
+-
5
))
```
%% Output
-5
%% Cell type:code id: tags:
```
python
print
(
-
2
--
2
-
2
)
```
%% Output
-2
%% Cell type:code id: tags:
```
python
print
(
5
-
2
**
(
-
1
*-
1
))
```
%% Output
3
%% Cell type:code id: tags:
```
python
print
(
-
(
1
*
1
*
2
*
3
*
5
*-
8
))
```
%% Output
240
%% Cell type:markdown id: tags:
## Oppgave 2
%% Cell type:markdown id: tags:
**Hva tilsvarer 80 grader celsius i Fahrenheit?**
$$F =
\f
rac{9}{5}Celsius + 32$$
%% Cell type:code id: tags:
```
python
#Rett frem
print
(
9
/
5
*
80
+
32
)
#Ved hjelp av variabel
degrees_celcius
=
80
F
=
(
9
/
5
)
*
degrees_celcius
+
32
print
(
F
)
#Bonus: Omregningen kan også skrives ut som en setning
print
(
f
'
{
degrees_celcius
}
grader celcius tilsvarer
{
F
}
grader fahrenheit
'
)
```
%% Output
176.
0
176.
0
80 grader celcius tilsvarer 176.0 grader fahrenheit
%% Cell type:markdown id: tags:
## Oppgave 3
%% Cell type:markdown id: tags:
**Hva returneres ved å regne ut følgende uttrykk i Python?**
$$
\f
rac{7!}{5!-3}$$
%% Cell type:markdown id: tags:
*Merk at 7! er fakultetet av 7 og kan skrives som $ 7! = 7*
6
*5*
4
*3*
2
*1$*
%% Cell type:code id: tags:
```
python
# Rett frem
print
((
7
*
6
*
5
*
4
*
3
*
2
*
1
)
/
((
5
*
4
*
3
*
2
*
1
)
-
3
))
# Bonus: ved hjelp av math-modulen
import
math
print
(
math
.
factorial
(
7
)
/
(
math
.
factorial
(
5
)
-
3
))
```
%% Output
43.
07692307692308
43.
07692307692308
%% Cell type:markdown id: tags:
## Oppgave 4
%% Cell type:markdown id: tags:
**Er 1000 000 000 større enn $2^{30}$?**
%% Cell type:code id: tags:
```
python
print
(
1000000000
>
2
**
30
)
```
%% Output
False
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment