Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
INF-TC1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hahn Robin
INF-TC1
Commits
b33119a5
Commit
b33119a5
authored
1 year ago
by
Hahn Robin
Browse files
Options
Downloads
Patches
Plain Diff
Update INF-TC1-td02.ipynb
parent
59809971
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
TD02/INF-TC1-td02.ipynb
+57
-7
57 additions, 7 deletions
TD02/INF-TC1-td02.ipynb
with
57 additions
and
7 deletions
TD02/INF-TC1-td02.ipynb
+
57
−
7
View file @
b33119a5
...
...
@@ -247,7 +247,13 @@
"outputs": [],
"source": [
"def average_grade(L: list)-> int:\n",
" # YOUR CODE HERE\n",
" def average_grade(L:list)-> int:
moyenne = 0
N = len(L)
for student in L:
moyenne+= int(student['note'])
moyenne = moyenne/N
return(moyenne),
" raise NotImplementedError()"
]
},
...
...
@@ -322,7 +328,16 @@
"outputs": [],
"source": [
"def find_maximum_recursive(L: list)-> str:\n",
" # YOUR CODE HERE\n",
" def find_maximum_recursive(L:list)->int:
m = float(L[-1]['note'])
if len(L) == 1:
return float(L[0]['note'])
else:
n = len(L)
L=L[:n-1]
if float(find_maximum_recursive(L))>m:
m = float(find_maximum_recursive(L))
return m,
" raise NotImplementedError()"
]
},
...
...
@@ -371,7 +386,14 @@
"outputs": [],
"source": [
"def find_same_grade(L: list)-> tuple:\n",
" # YOUR CODE HERE\n",
" def find_same_grade(L:list)->tuple:
l=[int(student['note']) for student in L]
S = set({})
for i in range(len(l)):
for j in range(len(l)):
if (l[i],j) in S and i!=j:
return (L[i]['nom'],L[j]['nom'])
S.add((l[i],i)),
" raise NotImplementedError()"
]
},
...
...
@@ -441,7 +463,18 @@
"outputs": [],
"source": [
"def sort_selection(L: list, key=lambda x: x) -> list:\n",
" # YOUR CODE HERE\n",
" def sort_selection(L:list,critere:str)->list:
n = len(L)
for i in range(0,n-1):
minimum = i
for j in range(minimum,n):
if L[j][critere] < L[minimum][critere]:
minimum = j
if min != i:
val = L[i]
L[i] = L[minimum]
L[minimum] = val
return L,
" raise NotImplementedError()"
]
},
...
...
@@ -570,7 +603,9 @@
"source": [
"pile = queue.LifoQueue()\n",
"s = Stack()\n",
"# YOUR CODE HERE\n",
"for etu in students_list:
s.push(etu)
pile.put(etu)",
"raise NotImplementedError()\n",
"\n",
"while not s.is_empty() and not pile.empty():\n",
...
...
@@ -606,7 +641,20 @@
"outputs": [],
"source": [
"class Queue():\n",
" # YOUR CODE HERE\n",
"
class Queue:
def __init__(self):
self.items = []
def push(self,item):
self.items.append(item)
def pop(self):
if not self.is_empty():
return self.items.pop(0)
def peek(self):
if not self.is_empty():
return self.items[0]
def is_empty(self):
return len(self.items) == 0",
" raise NotImplementedError()"
]
},
...
...
@@ -632,7 +680,9 @@
"source": [
"file = queue.Queue()\n",
"f = Queue()\n",
"# YOUR CODE HERE\n",
"for etu in students_list:
f.push(etu)
file.put(etu)",
"raise NotImplementedError()\n",
"\n",
"while not f.is_empty() and not file.empty():\n",
...
...
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