From 3bafad3b799c44ecb9f40b52c25ded836d6c69d0 Mon Sep 17 00:00:00 2001 From: ceciliawambui <47850604+ceciliawambui@users.noreply.github.com> Date: Thu, 25 Feb 2021 07:57:49 +0300 Subject: [PATCH 1/5] A function to return an odd or even number --- Even_Odd.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Even_Odd.py diff --git a/Even_Odd.py b/Even_Odd.py new file mode 100644 index 0000000..7f9d8df --- /dev/null +++ b/Even_Odd.py @@ -0,0 +1,7 @@ +# Create a function (or write a script in Shell) that takes an integer as +# an argument and returns "Even" for even numbers or "Odd" for odd numbers. +def even_or_odd(number): + if number % 2 == 0: + return "Even" + else: + return "Odd" \ No newline at end of file From 25f064b38656b566d92f2227f3eb439fd79d3221 Mon Sep 17 00:00:00 2001 From: ceciliawambui <47850604+ceciliawambui@users.noreply.github.com> Date: Thu, 25 Feb 2021 08:28:19 +0300 Subject: [PATCH 2/5] A function to count the vowels in a string --- vowel_count.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 vowel_count.py diff --git a/vowel_count.py b/vowel_count.py new file mode 100644 index 0000000..025f098 --- /dev/null +++ b/vowel_count.py @@ -0,0 +1,8 @@ +def get_count(input_str): + input_str="PYTHON is fun" + for char in input_str: + if char in "aeiouAEIOU": + num_vowels = num_vowels+1 + + # your code here + return num_vowels \ No newline at end of file From 6913a9ec8fbf2d314de46d9805805ba24a4506ad Mon Sep 17 00:00:00 2001 From: ceciliawambui <47850604+ceciliawambui@users.noreply.github.com> Date: Thu, 25 Feb 2021 08:39:46 +0300 Subject: [PATCH 3/5] Function to get the first non repeating character --- First_non_repeating.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 First_non_repeating.py diff --git a/First_non_repeating.py b/First_non_repeating.py new file mode 100644 index 0000000..2d76f0e --- /dev/null +++ b/First_non_repeating.py @@ -0,0 +1,17 @@ +# Write a function named first_non_repeating_letter that takes a +# string input, and returns the first character that is not repeated anywhere in the string. +#For example, if given the input 'stress',the function should return 't', since the letter +#t only occurs once in the string, and occurs first in the string. +#As an added challenge, upper- and lowercase letters are considered the same character, but the function +#should return the correct case for the initial letter. For example,the input 'sTreSS' should return 'T'. +#If a string contains all repeating characters, it should return an empty string ("") or None -- see sample tests. +def first_non_repeating_letter(string): + string_upper = string.upper() + upper_string = list(string_upper) + string_length = len(upper_string) + for i in range(0,string_length): + if upper_string.count(upper_string[i]) == 1: + return string[i] + else: + continue + return "" \ No newline at end of file From b780fcc8db6de7facea1aa87edae7b265116a486 Mon Sep 17 00:00:00 2001 From: ceciliawambui <47850604+ceciliawambui@users.noreply.github.com> Date: Thu, 25 Feb 2021 08:49:24 +0300 Subject: [PATCH 4/5] A function to multiply two numbers --- multiply.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 multiply.py diff --git a/multiply.py b/multiply.py new file mode 100644 index 0000000..1350cf2 --- /dev/null +++ b/multiply.py @@ -0,0 +1,4 @@ +# A function to multiply two numbers +def multiply(a, b): + result=a * b + return result \ No newline at end of file From 33a130bc55e77b781825f1e7bcd109aa13f81e51 Mon Sep 17 00:00:00 2001 From: ceciliawambui <47850604+ceciliawambui@users.noreply.github.com> Date: Fri, 26 Feb 2021 08:01:11 +0300 Subject: [PATCH 5/5] Function for the sum of digits and digital root. --- sum_of_digits.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 sum_of_digits.py diff --git a/sum_of_digits.py b/sum_of_digits.py new file mode 100644 index 0000000..39b4343 --- /dev/null +++ b/sum_of_digits.py @@ -0,0 +1,5 @@ +def digital_root(n): + if(n < 10): + return n + n=n%10+digital_root(n//10) + return digital_root(n) \ No newline at end of file