diff options
Diffstat (limited to 'challenge-273/eric-cheung/python/ch-1.py')
| -rwxr-xr-x | challenge-273/eric-cheung/python/ch-1.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/challenge-273/eric-cheung/python/ch-1.py b/challenge-273/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..e01e8f5dca --- /dev/null +++ b/challenge-273/eric-cheung/python/ch-1.py @@ -0,0 +1,31 @@ +
+def round(dInput):
+ return int(dInput) + (1 if dInput - int(dInput) >= 0.5 else 0)
+
+## Example 1
+strInput = "perl"
+strChar = "e"
+
+## Example 2
+## strInput = "java"
+## strChar = "a"
+
+## Example 3
+## strInput = "python"
+## strChar = "m"
+
+## Example 4
+## strInput = "ada"
+## strChar = "a"
+
+## Example 5
+## strInput = "ballerina"
+## strChar = "l"
+
+## Example 6
+## strInput = "analitik"
+## strChar = "k"
+
+nPercent = round(strInput.count(strChar) * 100 / len(strInput))
+
+print (nPercent)
|
