Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IOT - Worksheet 2 part 1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
jo2-holdsworth
IOT - Worksheet 2 part 1
Commits
7966caa5
Commit
7966caa5
authored
2 years ago
by
jo2-holdsworth
Browse files
Options
Downloads
Patches
Plain Diff
most of task 2 done + readme
parents
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+62
-0
62 additions, 0 deletions
README.md
morse.py
+97
-0
97 additions, 0 deletions
morse.py
with
159 additions
and
0 deletions
README.md
0 → 100644
+
62
−
0
View file @
7966caa5
# Internet Of Things - Worksheet 2 part 1

**Module Name:**
Internet Of Things
**Module Code:**
UFCFVK‑15‑2
**Module Leader Name:**
Benedict R. Gaster
-
[
Internet Of Things - Worksheet 2 part 1
](
#internet-of-things---worksheet-2-part-1
)
-
[
Description
](
#description
)
-
[
Getting Started
](
#getting-started
)
-
[
Dependencies
](
#dependencies
)
-
[
Installing
](
#installing
)
-
[
Executing program
](
#executing-program
)
-
[
Authors
](
#authors
)
-
[
Version History
](
#version-history
)
-
[
License
](
#license
)
## Description
Morse code :: Worksheet(2 part 1)
A program to encode and decode morse.
*
Task 1
*
Task 2
## Getting Started
### Dependencies
*
### Installing
*
pip install -r requirments.txt
### Executing program
```
python3 morse.py
```
## Authors
Contributors names and contact info
ex. Jack Holdsworth @
[
my website
](
https://holdsworth.dev
)
## Version History
*
0.2
*
most of task 2 done
*
README made
*
0.1
*
init.
## License
This project is licensed under the GPL License - see the LICENSE.md file for details
This diff is collapsed.
Click to expand it.
morse.py
0 → 100644
+
97
−
0
View file @
7966caa5
class
node
:
def
__init__
(
self
,
value
,
left
=
None
,
right
=
None
):
self
.
value
=
value
self
.
leftChildNode
=
left
self
.
rightChildNode
=
right
def
setLeftChildNode
(
self
,
nodes
):
self
.
leftChildNode
=
nodes
def
setRightChildNode
(
self
,
nodes
):
self
.
rightChildNode
=
nodes
def
hasLeftChildNode
(
self
):
if
self
.
leftChildNode
!=
None
:
return
True
else
:
return
False
def
hasRightChildNode
(
self
):
if
self
.
rightChildNode
!=
None
:
return
True
else
:
return
False
def
printNode
(
self
,
level
=
1
,
direction
=
"
S
"
):
for
x
in
range
(
level
):
print
(
"
"
,
end
=
''
)
print
(
direction
+
"
"
+
str
(
self
.
value
))
if
self
.
hasLeftChildNode
()
==
True
:
self
.
leftChildNode
.
printNode
((
level
+
1
),
"
L
"
)
if
self
.
hasRightChildNode
()
==
True
:
self
.
rightChildNode
.
printNode
((
level
+
1
),
"
R
"
)
def
words
(
self
,
values
):
if
values
:
x
=
values
.
split
(
"
"
)
decodes
=
[]
for
y
in
x
:
print
(
self
.
value
)
print
(
"
HELLO
"
+
y
)
decodes
.
append
(
self
.
decode
(
y
))
# print(self.decode(y))
return
decodes
def
decode
(
self
,
values
):
print
(
values
)
if
values
:
if
values
[
0
]
==
"
.
"
:
return
self
.
leftChildNode
.
decode
(
values
[
1
:])
elif
values
[
0
]
==
"
-
"
:
return
self
.
rightChildNode
.
decode
(
values
[
1
:])
else
:
print
(
"
ERROR
"
)
else
:
return
self
.
value
def
encode
():
#dictionary ie e == --.-.-.-..-
x
=
x
alphabet
=
[
"
E
"
,
"
T
"
,
"
I
"
,
"
A
"
,
"
N
"
,
"
M
"
,
"
S
"
,
"
U
"
,
"
R
"
,
"
W
"
,
"
D
"
,
"
K
"
,
"
G
"
,
"
O
"
,
"
H
"
,
"
V
"
,
"
F
"
,
""
,
"
L
"
,
""
,
"
P
"
,
""
,
"
J
"
,
"
B
"
,
"
X
"
,
"
C
"
,
"
Y
"
,
"
Z
"
,
"
Q
"
,
""
,
""
]
queue
=
[]
start
=
node
(
"
start
"
)
queue
.
append
(
start
)
count
=
0
while
count
<
len
(
alphabet
)
-
1
:
# print(count)
parent
=
queue
.
pop
(
0
)
# print(parent.value)
# print(alphabet[count])
childLeft
=
node
(
alphabet
[
count
])
parent
.
setLeftChildNode
(
childLeft
)
queue
.
append
(
childLeft
)
count
+=
1
childRight
=
node
(
alphabet
[
count
])
parent
.
setRightChildNode
(
childRight
)
queue
.
append
(
childRight
)
count
+=
1
start
.
printNode
()
print
(
start
.
words
(
"
..- ..-
"
))
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