Skip to content

Added a dictionary folder and placed two python programs inside that #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Dictionary/checkStrings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# A program to check whether the string contains equal & same no of characters
import collections


def check_strings(word1, word2):
word1 = list(word1)
word2 = list(word2)
dict1 = {}
dict2 = {}
flag = True
for i in word1:
if i in dict1:
dict1[i] = dict1[i] + 1
continue
else:
dict1[i] = 1
for i in word2:
if i in dict2:
dict2[i] = dict2[i] + 1
continue
else:
dict2[i] = 1
if len(dict1) == len(dict2):
for k, v in dict1.items():
if k in dict2:
if dict2[k] == v:
continue
else:
flag = False
break
else:
flag = False
break
if flag:
print("Same")
else:
print("Not Same")


def main():
word1 = input("Enter first string : ")
word2 = input("Enter second string : ")
check_strings(word1, word2)
word = "madam"


main()
21 changes: 21 additions & 0 deletions Dictionary/frequencyCount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# A python program to calculate the frequency of each character in the string
def count_frquency(word):
val=dict()
word=list(word)
for i in word:
if i in val:
val[i]=val[i]+1
continue
else:
val[i]=1
print(word)
return val


def main():
word=input("Enter a string whose frequency you want to calculate ")
print(word)
print("Frequency of respective characters in {0} is {1}".format(word,count_frquency(word)))

main()