Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
examen
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GUYOT Maelis
examen
Commits
93d0c092
Commit
93d0c092
authored
7 months ago
by
GUYOT Maelis
Browse files
Options
Downloads
Patches
Plain Diff
question4
parent
763dd82f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examen.py
+21
-5
21 additions, 5 deletions
examen.py
with
21 additions
and
5 deletions
examen.py
+
21
−
5
View file @
93d0c092
#Imports éventuels
#Imports éventuels
import
itertools
as
it
#AJouts de fonctions et méthode
#AJouts de fonctions et méthode
class
TabletteChocolat
:
class
TabletteChocolat
:
#création de la classe
def
__init__
(
self
,
m
,
n
):
def
__init__
(
self
,
m
,
n
):
#initialisation du constructeur
self
.
n
=
n
self
.
n
=
n
self
.
m
=
m
self
.
m
=
m
if
not
isinstance
(
n
,
int
)
or
isinstance
(
m
,
int
):
if
not
isinstance
(
n
,
int
)
or
not
isinstance
(
m
,
int
):
#permet de sortir une erreur si m et n ne sont pas entiers
raise
TypeError
raise
TypeError
def
__str__
(
self
):
#surcharge de str
return
"
Tablette de Chocolat
"
+
str
(
self
.
m
)
+
"
x
"
+
str
(
self
.
n
)
def
__repr__
(
self
):
#surcharge de repr
return
"
Tablette de chocolat de
"
+
str
(
self
.
m
)
+
"
x
"
+
str
(
self
.
n
)
def
coups_possibles
(
self
):
g
=
[]
for
i
in
range
(
self
.
m
):
for
j
in
range
(
self
.
n
):
g
.
append
(
i
,
j
)
return
g
#Programme principal
#Programme principal
if
__name__
=
'
main
'
#if __name__=='main':
\ No newline at end of file
t
=
TabletteChocolat
(
3
,
4
)
g
=
t
.
coups_possibles
()
print
(
t
)
print
(
g
)
\ 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