Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
apt_exercises
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Andreas Fischer
apt_exercises
Compare revisions
a82ad08d68b99b220203c9021891514dafc02335 to master
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
afischer/apt_exercises
Select target project
No results found
master
Select Git revision
Branches
master
Swap
Target
ma18960/apt_exercises
Select target project
ll21215/apt_exercises
hb09106/apt_exercises
afischer/apt_exercises
sm27496/apt2020
ia19390/apt_exercises
pk02862/apt_exercises
cd28198/apt_exercises
ma05240/apt_exercises
jp01114/apt_exercises
mf19908/apt_exercises
an25923/apt_exercises
ma18960/apt_exercises
fa30968/apt_exercises
jg08184/apt_exercises
gs27324/apt_exercises
ss18986/apt_exercises
16 results
a82ad08d68b99b220203c9021891514dafc02335
Select Git revision
Branches
ma18960-master-patch-58670
master
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (1)
Added Clean Code exercise
· 3202f16e
Andreas Fischer
authored
3 years ago
3202f16e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Clean_Code/digitsum.py
+21
-0
21 additions, 0 deletions
Clean_Code/digitsum.py
Clean_Code/example.py
+20
-0
20 additions, 0 deletions
Clean_Code/example.py
with
41 additions
and
0 deletions
Clean_Code/digitsum.py
0 → 100644
View file @
3202f16e
b
=
"
00123456
"
i
=
0
temp1
=
0
while
i
<
len
(
b
):
a
=
b
[
i
]
a
=
int
(
a
)
temp1
=
temp1
+
a
i
+=
1
print
(
temp1
)
c
=
input
(
"
Please enter a number:
"
)
j
=
0
temp2
=
0
while
j
<
len
(
c
):
d
=
c
[
j
]
d
=
int
(
d
)
temp2
=
temp2
+
d
j
+=
1
print
(
temp2
)
x
=
temp1
-
temp2
print
(
"
The difference is:
"
,
x
)
This diff is collapsed.
Click to expand it.
Clean_Code/example.py
0 → 100644
View file @
3202f16e
def
myfunc
(
values
,
value
,
next
):
"""
This function will search an item in a list of values and return the neighbouring value -- either the successor or the predecessor.
"""
# First: find the position of value
i
=
-
1
for
j
in
range
(
len
(
values
)):
v
=
values
[
j
]
if
v
==
value
:
i
=
j
# If next == True get the successor
if
next
:
if
i
<
len
(
values
)
-
1
:
k
=
i
+
1
return
values
[
k
]
else
:
if
i
>
0
:
l
=
i
-
1
return
values
[
l
]
This diff is collapsed.
Click to expand it.