Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Kreetisingh wants to merge1 commit intoOmkarPathak:master
base:master
Choose a base branch
Loading
fromKreetisingh:master
Open
Show file tree
Hide file tree
Changes fromall 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 deletionsDictionary/checkStrings.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionsDictionary/frequencyCount.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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()


[8]ページ先頭

©2009-2025 Movatter.jp