From c3e5784d54d2352d14fbc85b6502328aac25f937 Mon Sep 17 00:00:00 2001 From: Vaibhavpan02 <89473295+Vaibhavpan02@users.noreply.github.com> Date: Sun, 30 Oct 2022 20:27:36 +0530 Subject: [PATCH 1/2] Create NumberOfVowel.py --- Python/NumberOfVowel.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Python/NumberOfVowel.py diff --git a/Python/NumberOfVowel.py b/Python/NumberOfVowel.py new file mode 100644 index 0000000..297e248 --- /dev/null +++ b/Python/NumberOfVowel.py @@ -0,0 +1,19 @@ +# Program to count the number of each vowels + +# string of vowels +vowels = 'aeiou' + +ip_str = 'Hello, have you tried our tutorial section yet?' + +# make it suitable for caseless comparisions +ip_str = ip_str.casefold() + +# make a dictionary with each vowel a key and value 0 +count = {}.fromkeys(vowels,0) + +# count the vowels +for char in ip_str: + if char in count: + count[char] += 1 + +print(count) From 9a581530ccfb3f4f92d17215f1d2d9a3781664e2 Mon Sep 17 00:00:00 2001 From: Vaibhavpan02 <89473295+Vaibhavpan02@users.noreply.github.com> Date: Sun, 30 Oct 2022 20:29:43 +0530 Subject: [PATCH 2/2] Create Selection_Sort.py --- Python/Selection_Sort.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Python/Selection_Sort.py diff --git a/Python/Selection_Sort.py b/Python/Selection_Sort.py new file mode 100644 index 0000000..eafd685 --- /dev/null +++ b/Python/Selection_Sort.py @@ -0,0 +1,18 @@ +# Selection sort in Python +def selectionSort(array, size): + + for ind in range(size): + min_index = ind + + for j in range(ind + 1, size): + # select the minimum element in every iteration + if array[j] < array[min_index]: + min_index = j + # swapping the elements to sort the array + (array[ind], array[min_index]) = (array[min_index], array[ind]) + +arr = [-2, 45, 0, 11, -9,88,-97,-202,747] +size = len(arr) +selectionSort(arr, size) +print('The array after sorting in Ascending Order by selection sort is:') +print(arr)