-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from AbuBakkar32/Abu-Bakkar
Abu bakkar
- Loading branch information
Showing
4 changed files
with
67 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,22 @@ | ||
import time | ||
from datetime import datetime | ||
from string import punctuation | ||
|
||
vowels = 'aeiou' # This is Vowels character | ||
text = 'Hello every one my name is abu bakkar siddik. i am from bangladesh. i am studing as a software engineer under daffodil international university. my dreame so long and may Allah full fill my dreams' | ||
text = text.casefold() | ||
count = {}.fromkeys(vowels, 0) | ||
|
||
cons = {} | ||
|
||
for char in text: | ||
if char in count: | ||
count[char] += 1 | ||
else: | ||
cons[char] = cons.get(char, 0)+1 | ||
|
||
print(f'The Vowels is : {count}', end=" ") | ||
print("") | ||
print(f'The consonants is : {cons}', end=" ") | ||
|
||
# simple code for remove punctuation character | ||
data = {} | ||
for i, j in cons.items(): | ||
if i in punctuation: | ||
continue | ||
if i == ' ': | ||
continue | ||
else: | ||
data[i] = j | ||
|
||
print('\n<<<<<<<<<<This the clear item count after processing data>>>>>>>>>>') | ||
print(data) | ||
|
||
|
||
# Constants | ||
VOWELS = 'aeiou' | ||
TEXT = ( | ||
'Hello every one my name is abu bakkar siddik. i am from bangladesh. ' | ||
'I am studying as a software engineer under daffodil international university. ' | ||
'My dream is so long and may Allah fulfill my dreams' | ||
).casefold() | ||
|
||
# Initialize counts | ||
counts = {char: 0 for char in VOWELS} | ||
consonants = {} | ||
|
||
# Count vowels and consonants | ||
for char in TEXT: | ||
if char in VOWELS: | ||
counts[char] += 1 | ||
elif char.isalpha(): # Count only alphabetic characters as consonants | ||
consonants[char] = consonants.get(char, 0) + 1 | ||
|
||
# Output the results | ||
print(f'The Vowels are: {counts}') | ||
print(f'The consonants are: {consonants}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import string | ||
import re | ||
from collections import Counter | ||
|
||
# Define the sentence | ||
sentence = ("my name is Rakib. " | ||
"are your know me? hey Rakib your are so smart and sexy!. " | ||
"i love you Rakib." | ||
).casefold() | ||
|
||
# Remove punctuation and numbers | ||
cleaned_sentence = re.sub(r'[^\w\s]', '', sentence) | ||
cleaned_sentence = re.sub(r'\d+', '', cleaned_sentence) | ||
|
||
# Split the sentence into words | ||
words = cleaned_sentence.split() | ||
|
||
# Count the occurrences of each word | ||
word_count = Counter(words) | ||
|
||
# Print the word count | ||
for word, count in word_count.items(): | ||
print(f"{word}: {count}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters