Skip to content

Commit

Permalink
Merge pull request #242 from AbuBakkar32/Abu-Bakkar
Browse files Browse the repository at this point in the history
Abu bakkar
  • Loading branch information
AbuBakkar32 authored Jun 5, 2024
2 parents eda2ed2 + 5d12901 commit acac02f
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 57 deletions.
57 changes: 22 additions & 35 deletions Python Basic/vowels count.py
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}')
23 changes: 23 additions & 0 deletions Python Basic/word_count.py
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}")
41 changes: 21 additions & 20 deletions Python Essential/String_formating.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@
# https://towardsdatascience.com/3-methods-for-aggregating-data-with-python-pandas-14ceb75b6f6e
# https://towardsdatascience.com/create-a-butterfly-chart-easily-using-plotly-aa3d43ba410d
# https://medium.com/@avinashchandrana/comparison-of-matplotlib-vs-seaborn-and-plotly-on-a-dataset-for-beginners-92a7e8197dc6
import decimal

# text = "hello world"
# print(f"{text:^20}")
#
# number = 1234567890
# print(f"{number:,}")
#
# number = 123
# print(f"{number:08}")
#
# number = 254.3463
# print(f"{f'${number:.3f}':}")
text = "hello world"
print(f"{text:^20}")

number = 1234567890
print(f"{number:,}")

number = 123
print(f"{number:08}")

number = 254.3463
print(f"{f'${number:.3f}':}")


# x, y = "Hello", "World"
Expand All @@ -37,14 +38,14 @@
# print(Template("$x $y").substitute(x=x, y=y)) # 1.24 usec per loop - Slow!


# value = decimal.Decimal("42.12345")
# print(f"output: {value:{0}.{3}}")
#
# value = decimal.Decimal("42.12345")
# print(f'Result: {value:{"4.3" if value < 100 else "8.3"}}')
#
# value = decimal.Decimal("142.12345")
# print(f'Result: {value:{"4.2" if value < 100 else "8.3"}}')
value = decimal.Decimal("42.12345")
print(f"output: {value:{0}.{3}}")

value = decimal.Decimal("42.12345")
print(f'Result: {value:{"4.3" if value < 100 else "8.3"}}')

value = decimal.Decimal("142.12345")
print(f'Result: {value:{"4.2" if value < 100 else "8.3"}}')


# print(f"{(lambda x: x**2)(3)}")
print(f"{(lambda x: x**2)(3)}")
3 changes: 1 addition & 2 deletions Python Essential/print build in function.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ def print_all_namata_tables():


if __name__ == "__main__":
pass
# print_all_namata_tables()
print_all_namata_tables()

0 comments on commit acac02f

Please sign in to comment.