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 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 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 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 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