Add python/raindrops

This commit is contained in:
dwrz
2021-11-12 21:16:26 +00:00
parent d83e227af4
commit 3b61491cbb
6 changed files with 188 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
"""This module provides a function to convert a number into a string that
contains raindrop sounds corresponding to certain potential factors."""
def convert(number):
"""Converts a number into a string that contains raindrop sounds
corresponding to certain potential factors."""
sound = ""
digit=True
if number % 3 == 0:
sound += "Pling"
digit=False
if number % 5 == 0:
sound += "Plang"
digit=False
if number % 7 == 0:
sound += "Plong"
digit=False
if digit: sound = f"{ number }"
return sound