diff --git a/week6/3-Forecast/forecast.py b/week6/3-Forecast/forecast.py new file mode 100644 index 0000000..dd9587e --- /dev/null +++ b/week6/3-Forecast/forecast.py @@ -0,0 +1,29 @@ +def forecast(days): + d = {"rain": 0, 'sunshine': 0, 'snow': 0} + tomorrow = '' + li = [] + for item in days: + if item == 'rain': + d['rain'] += 1 + if item == 'sunshine': + d['sunshine'] += 1 + if item == 'snow': + d['snow'] += 1 + for values in d.values(): + li.append(values) + li.sort() + print(li) + if li[2] > li[1]: + for key, value in d.items(): + if value == li[2]: + tomorrow = key + if li[2] == li[1]: + if li[2] == li[0]: + tomorrow = days[len(days)-1] + else: + for key, value in d.items(): + if value == li[0]: + tomorrow = key + return tomorrow + +print(forecast(["rain", "rain", "sunshine", "sunshine"])) \ No newline at end of file diff --git a/week6/3-Forecast/solutions/forecast.py b/week6/3-Forecast/solutions/forecast.py new file mode 100644 index 0000000..dd9587e --- /dev/null +++ b/week6/3-Forecast/solutions/forecast.py @@ -0,0 +1,29 @@ +def forecast(days): + d = {"rain": 0, 'sunshine': 0, 'snow': 0} + tomorrow = '' + li = [] + for item in days: + if item == 'rain': + d['rain'] += 1 + if item == 'sunshine': + d['sunshine'] += 1 + if item == 'snow': + d['snow'] += 1 + for values in d.values(): + li.append(values) + li.sort() + print(li) + if li[2] > li[1]: + for key, value in d.items(): + if value == li[2]: + tomorrow = key + if li[2] == li[1]: + if li[2] == li[0]: + tomorrow = days[len(days)-1] + else: + for key, value in d.items(): + if value == li[0]: + tomorrow = key + return tomorrow + +print(forecast(["rain", "rain", "sunshine", "sunshine"])) \ No newline at end of file diff --git a/week7/1-Taken-Name/solutions/surname.py b/week7/1-Taken-Name/solutions/surname.py new file mode 100644 index 0000000..c510ac5 --- /dev/null +++ b/week7/1-Taken-Name/solutions/surname.py @@ -0,0 +1,8 @@ +def taken_name(surname_husband, surname_wife): + if surname_husband in surname_wife: + return True + else: + return False + +print(taken_name("Petrov", "Ivanova-Petrova")) +print(taken_name("Andonov", "Karapitonova")) \ No newline at end of file diff --git a/week7/2-Coolest-Palindrome/solutions/is_string_palindrom.py b/week7/2-Coolest-Palindrome/solutions/is_string_palindrom.py new file mode 100644 index 0000000..337d872 --- /dev/null +++ b/week7/2-Coolest-Palindrome/solutions/is_string_palindrom.py @@ -0,0 +1,19 @@ +def is_string_palindrom(string): + new_string = '' + marks = [',', '.', '?', '!', ' '] + + for c in string: + if c not in marks: + new_string += c + + new_string = new_string.lower() + + for i in range(0, len(new_string)//2): + if new_string[i] == new_string[len(new_string)-1-i]: + continue + else: + return False + return True +print(is_string_palindrom("A Toyota!")) +print(is_string_palindrom("bozaa")) +print(is_string_palindrom(" kapak! ")) \ No newline at end of file