summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhongheng Liu <z.liu@outlook.com.gr>2025-01-30 09:38:59 +0200
committerZhongheng Liu <z.liu@outlook.com.gr>2025-01-30 09:38:59 +0200
commit4d873ac8e2e642118e04c1b5b1515e12cb655bde (patch)
treec1cfcbbbc2e0d35eacc4bc55a465349f07c6d37b
parente2c4e882f9a549e01553b60c61fdbe8b52238cbe (diff)
downloadcs-y13-4d873ac8e2e642118e04c1b5b1515e12cb655bde.tar.gz
cs-y13-4d873ac8e2e642118e04c1b5b1515e12cb655bde.tar.bz2
cs-y13-4d873ac8e2e642118e04c1b5b1515e12cb655bde.zip
feat(class): Activity 20C
-rw-r--r--.envrc4
-rw-r--r--linked_list/linked.py11
-rw-r--r--py-class.py10
3 files changed, 17 insertions, 8 deletions
diff --git a/.envrc b/.envrc
index 5bf8fc1..894571b 100644
--- a/.envrc
+++ b/.envrc
@@ -1,3 +1,3 @@
-source_url "https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc" "sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0="
+source_url "https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc" "sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k="
-use devenv \ No newline at end of file
+use devenv
diff --git a/linked_list/linked.py b/linked_list/linked.py
index cd5d36e..d3f0084 100644
--- a/linked_list/linked.py
+++ b/linked_list/linked.py
@@ -4,11 +4,11 @@ def generator(l, up, low, h):
linkedp = []
for i in range(l):
linked.append(random.randint(up, low) if i < h else None)
- if i == 0:
+ if i == h - 1:
linkedp.append(-1)
continue
- linkedp.append(i-1)
- return (linked, linkedp, h-1, -1, h)
+ linkedp.append(i+1)
+ return (linked, linkedp, 0, -1, h)
# my_list = [37, 18, 49, 77, 68, None, None, None, None, None]
# my_plist = [-1, 0, 1, 2, 3, 4, 5, 6, 7, -1]
def delete(element, my_list, my_plist, start, null, heap):
@@ -27,13 +27,12 @@ def delete(element, my_list, my_plist, start, null, heap):
return None
tmp_pointer = my_plist[index]
my_plist[index] = heap
- heap = index
my_plist[oldIndex] = tmp_pointer
LENGTH = 15
l,p,s,n,h = generator(LENGTH, 0, 100, round(LENGTH / 2))
for i in range(len(l)):
- print(f"[{i}]\t{l[i]}\t{p[i]}\t{'<- heap' if i == h else ''}")
+ print(f"[{i}]\t{l[i]}\t{p[i]}\t{'<- heap' if i == h else ''}{'<- root' if i == s else ''}")
print("-------")
delete(int(input("$ ")), l, p, s, n, h)
for i in range(len(l)):
- print(f"[{i}]\t{l[i]}\t{p[i]}\t{'<- heap' if i == h else ''}")
+ print(f"[{i}]\t{l[i]}\t{p[i]}\t{'<- heap' if i == h else ''}{'<- root' if i == s else ''}")
diff --git a/py-class.py b/py-class.py
new file mode 100644
index 0000000..de1440e
--- /dev/null
+++ b/py-class.py
@@ -0,0 +1,10 @@
+class Student:
+ def __init__(self, name: str, dateOfBirth: str, examMark: int):
+ self.__name = name
+ self.__dateOfBirth = dateOfBirth
+ self.__examMark = examMark
+ def displayExamMark(self):
+ print(f"{self.__name} got {self.__examMark} marks")
+
+myStudent = Student("Example Exampleperson", "1989-06-04", 69)
+myStudent.displayExamMark()