Skip to content
Snippets Groups Projects
Commit 44213a57 authored by Chinemerem Ohuabunwa's avatar Chinemerem Ohuabunwa
Browse files

A

parent daf96e3f
No related branches found
No related tags found
No related merge requests found
......@@ -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."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment