Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slide-snippets
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor statistics
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
Lassi Mäntylä
Slide-snippets
Commits
13453597
Commit
13453597
authored
2 years ago
by
Eero Häihälä
Browse files
Options
Downloads
Patches
Plain Diff
Update for error lecture
parent
1573ff4f
Branches
Branches containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+8
-0
8 additions, 0 deletions
README.md
functio_demo.py
+5
-1
5 additions, 1 deletion
functio_demo.py
stack_trace_demo.py
+8
-3
8 additions, 3 deletions
stack_trace_demo.py
user_error_demo.py
+0
-0
0 additions, 0 deletions
user_error_demo.py
with
21 additions
and
4 deletions
README.md
+
8
−
0
View file @
13453597
# Snippettejä
Repo on täynnä erinäisiä snippettejä joita voi tutkia ja käytetään luennoilla niin ettei tarvitse livenä ajatella.
## Virhe tietoisku
1.
Esittele
`user_error_demo.py`
koodi
2.
Näytä että väärä syöte tai nollalla jakaminen kaataa ohjelman
3.
Esittele
`funktio_demo.py`
4.
Yhdistä ja esittele
`stack_trace_demo.py`
5.
Näytä miltä virhe stacktracessa näyttää
1.
Ylin on uloin
This diff is collapsed.
Click to expand it.
functio_demo.py
+
5
−
1
View file @
13453597
...
...
@@ -6,4 +6,8 @@ def summaa(a, b):
# Käyttö
print
(
"
Print on funktio
"
)
print
(
summaa
(
2
,
2
))
a
=
1
b
=
2
print
(
summaa
(
a
,
b
))
# Edelleinen on sama kun
print
(
a
+
b
)
This diff is collapsed.
Click to expand it.
stack_trace_demo.py
+
8
−
3
View file @
13453597
...
...
@@ -2,7 +2,12 @@ def kysy_määrä(kohde):
return
int
(
input
(
f
'
Montako
{
kohde
}
?:
'
))
perunoita
=
kysy_määrä
(
"
perunaa
"
)
lautasia
=
kysy_määrä
(
"
lautasta
"
)
def
main
():
perunoita
=
kysy_määrä
(
"
perunaa
"
)
lautasia
=
kysy_määrä
(
"
lautasta
"
)
print
(
f
'
Joka lautaselle menee
{
perunoita
/
lautasia
}
perunaa!
'
)
print
(
f
'
Joka lautaselle menee
{
perunoita
/
lautasia
}
perunaa!
'
)
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
error_demo.py
→
user_
error_demo.py
+
0
−
0
View file @
13453597
File moved
This diff is collapsed.
Click to expand it.
Preview
0%
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