Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions additional_func.py

This file was deleted.

38 changes: 19 additions & 19 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ def fibonacci(n):

# New functions added without test cases(2)

def celsius_to_fahrenheit(celsius):
"""
Convert Celsius to Fahrenheit
"""
return (celsius * 9/5) + 32

def count_vowels(string):
"""
Count the number of vowels in a string
"""
vowels = 'aeiouAEIOU'
return sum(1 for char in string if char in vowels)

def is_palindrome(s):
"""
Check if a string is a palindrome
"""
s = ''.join(char.lower() for char in s if char.isalnum())
return s == s[::-1]
# def celsius_to_fahrenheit(celsius):
# """
# Convert Celsius to Fahrenheit
# """
# return (celsius * 9/5) + 32

# def count_vowels(string):
# """
# Count the number of vowels in a string
# """
# vowels = 'aeiouAEIOU'
# return sum(1 for char in string if char in vowels)

# def is_palindrome(s):
# """
# Check if a string is a palindrome
# """
# s = ''.join(char.lower() for char in s if char.isalnum())
# return s == s[::-1]
26 changes: 13 additions & 13 deletions test_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from main import Calculator, Greeter, factorial, is_prime, fibonacci
from additional_func import celsius_to_fahrenheit, count_vowels
#from additional_func import celsius_to_fahrenheit, count_vowels

def test_calculator_add():
calc = Calculator()
Expand Down Expand Up @@ -90,18 +90,18 @@ def test_fibonacci_edge_cases():
assert fibonacci(4) == [0, 1, 1, 2]

#from 2nd file
def test_celsius_to_fahrenheit():
assert celsius_to_fahrenheit(0) == 32
assert celsius_to_fahrenheit(100) == 212
assert celsius_to_fahrenheit(-40) == -40
assert round(celsius_to_fahrenheit(37), 2) == 98.60

def test_count_vowels():
assert count_vowels("hello") == 2
assert count_vowels("AEIOU") == 5
assert count_vowels("rhythm") == 0
assert count_vowels("The quick brown fox") == 5
assert count_vowels("") == 0
# def test_celsius_to_fahrenheit():
# assert celsius_to_fahrenheit(0) == 32
# assert celsius_to_fahrenheit(100) == 212
# assert celsius_to_fahrenheit(-40) == -40
# assert round(celsius_to_fahrenheit(37), 2) == 98.60

# def test_count_vowels():
# assert count_vowels("hello") == 2
# assert count_vowels("AEIOU") == 5
# assert count_vowels("rhythm") == 0
# assert count_vowels("The quick brown fox") == 5
# assert count_vowels("") == 0

if __name__ == "__main__":
pytest.main()