Skip to content
Snippets Groups Projects
Commit 95e19133 authored by nilsl99's avatar nilsl99
Browse files

Added Testing

parent 824ab69c
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
from Aufgabe03a import Stack, StackList
```
%% Cell type:code id: tags:
``` python
a = Stack()
b = StackList()
print(a)
print(b)
```
%% Output
[]
StackList()
%% Cell type:code id: tags:
``` python
a.push(1)
a.push(3)
b.push(1)
b.push(3)
print(a)
print(b)
```
%% Output
[1, 3]
3 -> 1
%% Cell type:code id: tags:
``` python
a.pop()
a.pop()
a.pop()
```
%% Output
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_10532\2639057022.py in <cell line: 3>()
1 a.pop()
2 a.pop()
----> 3 a.pop()
c:\Users\Nilsiraptor\Documents\Git\algo_blatt_03\Aufgabe03a.py in pop(self)
12 def pop(self):
13 if self.isEmpty():
---> 14 raise ValueError("The Stack is empty!")
15 element = self.stack[-1]
16 del self.stack[-1]
ValueError: The Stack is empty!
%% Cell type:code id: tags:
``` python
b.pop()
b.pop()
b.pop()
```
%% Output
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_10532\2945287303.py in <cell line: 3>()
1 b.pop()
2 b.pop()
----> 3 b.pop()
c:\Users\Nilsiraptor\Documents\Git\algo_blatt_03\Aufgabe03a.py in pop(self)
62 def pop(self):
63 if self.isEmpty():
---> 64 raise ValueError("The Stack is empty!")
65 value = self.first_element.value
66 self.first_element = self.first_element.next
ValueError: The Stack is empty!
%% Cell type:code id: tags:
``` python
print(a.size(), a.isEmpty())
print(b.size(), b.isEmpty())
```
%% Output
0 True
0 True
%% Cell type:code id: tags:
``` python
for i in range(10):
a.push(i)
b.push(i)
print(a)
print(b)
```
%% Output
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
9 -> 8 -> 7 -> 6 -> 5 -> 4 -> 3 -> 2 -> 1 -> 0
%% Cell type:code id: tags:
``` python
print(a.top())
print(b.top())
```
%% Output
9
9
%% Cell type:code id: tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment