Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pythontehtavatjamk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
M9278
pythontehtavatjamk
Commits
69c6e8ed
Commit
69c6e8ed
authored
4 years ago
by
pasi kanto
Browse files
Options
Downloads
Patches
Plain Diff
valmiit
parent
07b74b50
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.DS_Store
+0
-0
0 additions, 0 deletions
.DS_Store
harj_12/teht2.py
+0
-0
0 additions, 0 deletions
harj_12/teht2.py
harjoitustyo/python.py
+187
-0
187 additions, 0 deletions
harjoitustyo/python.py
with
187 additions
and
0 deletions
.DS_Store
0 → 100644
+
0
−
0
View file @
69c6e8ed
File added
This diff is collapsed.
Click to expand it.
harj_12/teht2.py
0 → 100644
+
0
−
0
View file @
69c6e8ed
This diff is collapsed.
Click to expand it.
harjoitustyo/python.py
0 → 100644
+
187
−
0
View file @
69c6e8ed
import
random
import
numpy
def
vaikeusaste3
():
luku
=
random
.
randrange
(
1
,
15
)
luku1
=
random
.
randrange
(
1
,
15
)
return
luku
,
luku1
def
vaikeusaste1
():
luku
=
random
.
randrange
(
1
,
5
)
luku1
=
random
.
randrange
(
1
,
5
)
return
luku
,
luku1
def
vaikeusaste2
():
luku
=
random
.
randrange
(
1
,
10
)
luku1
=
random
.
randrange
(
1
,
10
)
return
luku
,
luku1
print
(
"
Anna nimesi:
"
)
nimi
=
input
()
print
(
"
Hei
"
+
nimi
+
"
. Tervetuloa pelaamaan matikka peliä
"
)
while
True
:
print
(
"
Anna vaikeus aste välillä 1-5. Jos haluat lopettaa paina 0?
"
)
aste
=
int
(
input
())
pisteet
=
0
if
aste
==
1
:
i
=
0
while
i
<
11
:
lasku
=
vaikeusaste1
()
print
(
"
Laske yhteen
"
+
str
(
lasku
))
arvaus
=
int
(
input
())
summa1
=
sum
(
list
(
lasku
))
if
summa1
==
arvaus
:
print
(
"
Oikein
"
)
pisteet
+=
1
else
:
print
(
"
Väärin
"
)
i
+=
1
elif
aste
==
2
:
i
=
0
while
i
<
11
:
lasku
=
vaikeusaste2
()
print
(
"
Laske yhteen
"
+
str
(
lasku
))
arvaus
=
int
(
input
())
summa1
=
sum
(
list
(
lasku
))
if
summa1
==
arvaus
:
print
(
"
Oikein
"
)
pisteet
+=
1
else
:
print
(
"
Väärin
"
)
i
+=
1
if
aste
==
3
:
i
=
0
while
i
<
11
:
lasku
=
vaikeusaste3
()
print
(
"
Laske yhteen
"
+
str
(
lasku
))
arvaus
=
int
(
input
())
summa1
=
sum
(
list
(
lasku
))
if
summa1
==
arvaus
:
print
(
"
Oikein
"
)
pisteet
+=
1
else
:
print
(
"
Väärin
"
)
i
+=
1
if
aste
==
4
:
i
=
0
while
i
<
11
:
summa
=
vaikeusaste1
()
print
(
"
Laske tulo
"
+
str
(
summa
))
arvaus
=
int
(
input
())
summa1
=
numpy
.
prod
(
list
(
summa
))
if
summa1
==
arvaus
:
print
(
"
Oikein
"
)
pisteet
+=
1
else
:
print
(
"
Väärin
"
)
i
+=
1
if
aste
==
5
:
i
=
0
while
i
<
11
:
summa
=
vaikeusaste2
()
print
(
"
Laske tulo
"
+
str
(
summa
))
arvaus
=
int
(
input
())
summa1
=
numpy
.
prod
(
list
(
summa
))
if
summa1
==
arvaus
:
print
(
"
Oikein
"
)
pisteet
+=
1
else
:
print
(
"
Väärin
"
)
i
+=
1
if
aste
==
0
:
break
print
(
"
Sait pisteitä
"
+
str
(
pisteet
))
\ No newline at end of file
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