Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
session_14_code_testing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Chinemerem Ohuabunwa
session_14_code_testing
Commits
44213a57
Commit
44213a57
authored
8 months ago
by
Chinemerem Ohuabunwa
Browse files
Options
Downloads
Patches
Plain Diff
A
parent
daf96e3f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sample_code.py
+5
-2
5 additions, 2 deletions
sample_code.py
with
5 additions
and
2 deletions
sample_code.py
+
5
−
2
View file @
44213a57
...
...
@@ -6,18 +6,20 @@ def add(a, b):
def
subtract
(
a
,
b
):
"""
Subtract the second number from the first.
"""
assert
a
-
b
>=
0
,
"
This gives a negative value.
"
return
a
-
b
print
(
subtract
(
8
,
6
))
def
multiply
(
a
,
b
):
"""
Multiply two numbers.
"""
return
a
*
b
def
divide
(
a
,
b
):
"""
Divide the first number by the second, handling division by zero.
"""
assert
a
>
0
,
"
Numerator should be greater that zero
"
if
b
==
0
:
return
"
Cannot divide by zero
"
return
a
/
b
print
(
divide
(
1
,
2
))
def
power
(
base
,
exponent
):
"""
Raise a base number to an exponent.
"""
return
base
**
exponent
...
...
@@ -26,6 +28,7 @@ def is_palindrome(s):
"""
Check if a string is a palindrome (ignores case and spaces).
"""
s
=
s
.
replace
(
"
"
,
""
).
lower
()
return
s
==
s
[::
-
1
]
print
(
is_palindrome
(
"
Racecar
"
))
def
count_vowels
(
s
):
"""
Count the number of vowels in a string.
"""
...
...
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