INTERVIEW QUESTION - Count the frequency of words appearing in a string Using Python

  Рет қаралды 62,958

nETSETOS

nETSETOS

4 жыл бұрын

INTERVIEW QUESTION - Count the frequency of words appearing in a string Using Python
GitHub Link :- github.com/netsetos/python_co...
~-~~-~~~-~~-~
Please watch: "LRU Cache (With Python Code) "
• LRU Cache Implementati...
~-~~-~~~-~~-~

Пікірлер: 45
@khetrabasitechvideo362
@khetrabasitechvideo362 2 жыл бұрын
Thanks for quality videos
@sharmishthadevi7637
@sharmishthadevi7637 3 жыл бұрын
Awesome video
@pannagabm2100
@pannagabm2100 6 ай бұрын
Thank you❤
@siddhigolatkar8558
@siddhigolatkar8558 8 ай бұрын
Thank you
@shailesh__learning3848
@shailesh__learning3848 3 жыл бұрын
Thanks ..
@SumitKumar-ls6bq
@SumitKumar-ls6bq 2 жыл бұрын
Well, if you want you may not add, "d.keys()", instead you can use only d.
@aminemixes9304
@aminemixes9304 3 жыл бұрын
you can just do this : str = input("Enter a string: ") li=str.split() for val in li: con=li.count(val) print(f" {val} : {con}")
@learnvik
@learnvik 2 жыл бұрын
this doesn't work, it prints the occurrence twice of a single word. like if 'hello' is twice: it will show hello : 2 hello : 2
@kiranhinge22
@kiranhinge22 Жыл бұрын
very easy...it works
@safariyakm
@safariyakm 5 ай бұрын
d={} s=str(input("enter a string:" )) sp=s.split() for i in sp: d[i]=sp.count(i) print(d)
@Honey12682
@Honey12682 5 ай бұрын
a=input().split(" ") c=dict() for i in a: c[i]=a.count(i) print(c)
@MrMukulpandey
@MrMukulpandey 2 жыл бұрын
mam thats great...please keep making this videos as it will help us alot.
@techiewithcamera
@techiewithcamera 11 ай бұрын
My Solution: def f_words(s): dict={} for i in s: if i in dict.keys(): dict[i]+=1 else: dict[i]=1 print(dict)
@rohittiwari7019
@rohittiwari7019 9 ай бұрын
I am not able to understand this solution
@sumedhasen4534
@sumedhasen4534 3 жыл бұрын
It's a good tutorial. But ma'am can we consider fullstop as a word? Or can any other punctuation marks be considered as word?? please reply
@hbTrendsIn
@hbTrendsIn 7 ай бұрын
import re sentence = input("Enter a sentence: ") words = re.findall(r'\b\w+\b', sentence) word_counts = {} for word in words: count = sentence.count(word) word_counts[word] = count word_counts = {word: count for word, count in word_counts.items() if count > 1} print(word_counts)
@shantanuwanare5486
@shantanuwanare5486 2 жыл бұрын
To count frequency of letters : - def frequency_wor(): s = input("Enter the Letter : ") d = {} for i in s: if i in d: d[i] = d[i] + 1 else: d[i] = 1 print(d) frequency_wor()
@necronlord52
@necronlord52 6 ай бұрын
Yes, this one seems more elegant. Key initialization is an overkill even for beginners.
@kamleshnizare4633
@kamleshnizare4633 3 ай бұрын
s = input('Enter your string') output = { key:s.count(key) for key in s.split() }
@shantanuwanare5486
@shantanuwanare5486 2 жыл бұрын
def frequency_wor(): str = input("Enter the words : ") sp = str.split() d = {} for i in sp: if i in d: d[i] = d.get(i) + 1 else: d[i] = 1 print(d) frequency_wor()
@Kumar-tv8vp
@Kumar-tv8vp 3 ай бұрын
Nice bro
@PerfectBlue1412
@PerfectBlue1412 3 жыл бұрын
yeah I really like the tutorial but what is the intro for?
@ideatv2389
@ideatv2389 7 ай бұрын
details explanation before go into short way.
@jekhaarchana8207
@jekhaarchana8207 3 жыл бұрын
How to print this without colan?? I need to print as sheela1loves2mango2.... and so on..
@harishparamathmananda1385
@harishparamathmananda1385 5 ай бұрын
#Let's split this words based on space and store it in a list Ls = Sentence.split(' ') #remove the dot and other symbols Found_words = [] Repeated_times = [] for word in ls: if word not in Found_words: Found_words.append(word) Repeated_times.append(1) else: Idx= Found_words.index(word) Repeated_times[Idx] = Repeated_times[Idx] + 1 # now accessing the added words and based on the count greater than one, we are printing the result. For index, word in enumerate(Found_words): if Repeated_times[index] > 1: print(f"{Found_words[index]} founded {Repeated_times[index]}") ❤Happy coding 😊
@user-qx8xn7et5l
@user-qx8xn7et5l 6 ай бұрын
a = input('enter string:') c={} for i in a: if i in c: c[i] += 1 else: c[i] =1 print(c) this is working in simple way
@shaktipattnayak
@shaktipattnayak 2 ай бұрын
You need to split the string before iterating.
@andypandy1ify
@andypandy1ify Жыл бұрын
Two liner: def freq_words(): l=[i.strip(".").strip(".") for i in input("Enter a string: ").split()] for w in set(l): print(f"'{w}' : {l.count(w)}", end=", ")
@necronlord52
@necronlord52 6 ай бұрын
Not a Pythonian way - explicit should be preferred over implicit, simple over complicted. It will work, probably. But you shouldn't nest operations without any necessity.
@andypandy1ify
@andypandy1ify 6 ай бұрын
@@necronlord52 I disagree. The fewer the lines of code, the better. The time complexity and the space complexity of my solution would be smaller than a longer solution - my solution solves the problem quicker and uses less resources
@nothymasango8331
@nothymasango8331 8 ай бұрын
def Counting (sentence : str): results = {} string_list = sentence.strip().split() for i in string_list: results[i] = string_list.count(i) return results input = " Nothile loves eating mango apple , banana and aslo apple" print( Counting(input))
@hbTrendsIn
@hbTrendsIn 7 ай бұрын
import re sentence = input("Enter a sentence: ") words = re.findall(r'\b\w+\b', sentence) word_counts = {} for word in words: count = sentence.count(word) word_counts[word] = count word_counts = {word: count for word, count in word_counts.items() if count > 1} print(word_counts)
@-SUSHMASAI
@-SUSHMASAI 3 жыл бұрын
is this code working for anyone when iam trying to execute it not showing output
@priyanshilala994
@priyanshilala994 2 жыл бұрын
same
@yehualashetmengistu2505
@yehualashetmengistu2505 2 жыл бұрын
Same too
@successsuccess2786
@successsuccess2786 8 ай бұрын
Yes, it did.
@mrpresidentrestro
@mrpresidentrestro Жыл бұрын
dct = {} st = input("") lst = st.split() for i in lst: dct[i] = lst.count(i)
@darkshadow8414
@darkshadow8414 8 ай бұрын
Very good bro 🤜
@hamzaahmad3387
@hamzaahmad3387 Жыл бұрын
import re from collections import Counter s = s.strip('.') a = list(re.split('[. ]',s)) a.remove('') a = Counter(a) for k,v in a.items(): print(k,v)
@shubhamchoudhary5461
@shubhamchoudhary5461 3 жыл бұрын
I don't think that kind of Questions asked in interviews...
@Lj-pk2ee
@Lj-pk2ee 7 ай бұрын
ye question aa gya bhai, tumhari advice nhi suni, toh kr diya 😂
@TorchwoodTurtle11
@TorchwoodTurtle11 5 ай бұрын
I've had this exact question in two interviews now
@chavviM
@chavviM 4 ай бұрын
It has been asked for me in internal hiring for QA, QA is getting such questions.
@siddarthayadav8825
@siddarthayadav8825 Ай бұрын
then you don't watch
@sudarshansbhat8665
@sudarshansbhat8665 11 ай бұрын
Very bad explanation😢
Solve any Star Pattern program in Python
18:44
Simply Coding
Рет қаралды 892 М.
Smart Sigma Kid #funny #sigma #comedy
00:26
CRAZY GREAPA
Рет қаралды 20 МЛН
Sigma Kid Hair #funny #sigma #comedy
00:33
CRAZY GREAPA
Рет қаралды 35 МЛН
路飞被小孩吓到了#海贼王#路飞
00:41
路飞与唐舞桐
Рет қаралды 83 МЛН
Iron Chin ✅ Isaih made this look too easy
00:13
Power Slap
Рет қаралды 35 МЛН
Python Count Frequency: Count Frequency of Characters in String Python
7:46
Automate with Rakesh
Рет қаралды 1,9 М.
FIND MISSING NUMBER IN AN ARRAY IN PYTHON
11:23
nETSETOS
Рет қаралды 40 М.
Smart Sigma Kid #funny #sigma #comedy
00:26
CRAZY GREAPA
Рет қаралды 20 МЛН