0

letter frequency on python data structures

Guys please can you help me on the first project of python data structures im stuck please thank you on the letter frequency

24th Feb 2021, 11:20 AM
Mochizuki Hinata
Mochizuki Hinata - avatar
23 Answers
+ 20
Hope you're asking about this one :) stri=input() L= input() print(int(stri.count(L)/len(stri)*100))
8th Mar 2021, 11:29 AM
Prakhar
Prakhar - avatar
+ 11
LETTER FREQUENCY word=input() letter=input() n=len(word) per=((word.count(letter)/n)*100) print(int(per))
26th Mar 2021, 6:27 AM
Chaitu
Chaitu - avatar
+ 6
Please share your attempt for your project as well as add description details to your question.
24th Feb 2021, 11:36 AM
Shivani 📚✍
Shivani 📚✍ - avatar
+ 6
txt = input() lter = input() co = 0 for i in txt: if i == lter: co +=1 print(int(co/len(txt)*100))
7th May 2021, 7:20 AM
Aman Kaushik
Aman Kaushik - avatar
+ 4
Thank you very much, My last line was wrong
9th Mar 2021, 1:58 PM
Janindu Bashitha
Janindu Bashitha - avatar
+ 3
Thanks a lot!
4th May 2021, 8:05 AM
Konstantinos Sooutlis
Konstantinos Sooutlis - avatar
+ 3
letter frequency: text = input() letter = input() counter = text.count(letter) frequency = int ((counter/len(text)) * 100) print(frequency)
13th Jun 2021, 1:51 PM
NAJOUA ZEGRITTY
NAJOUA ZEGRITTY - avatar
+ 2
¿¿¿¿Just give a hint or something????
7th Mar 2021, 4:18 AM
Janindu Bashitha
Janindu Bashitha - avatar
+ 2
text = input() letter = input() x = text.count(letter) y = len(text) percentage = (x*100)/y print(int(percentage))
8th Aug 2021, 12:31 PM
Masoud Ramezani
Masoud Ramezani - avatar
+ 2
Here is my solution (hope it helps) text=input() letter=input() count=0 frequency=0 for c in text: if c==letter: count+=1 n=len(text) frequency=(count/n)*100 print(int(frequency))
21st Sep 2021, 3:56 PM
Hasnae BOUHMADY
Hasnae BOUHMADY - avatar
+ 2
#simple solution w = input() l =input() n=len(w) p =((w.count(l)/n)*100) print(int(p))
7th Apr 2023, 1:31 AM
Kesil Isaac
Kesil Isaac - avatar
+ 1
first = input() second = input() suum = first.count(second) div = len(first) total = (suum / div) * 100 print(int(total))
9th Aug 2021, 8:12 AM
Mozafar Hayaeian
Mozafar Hayaeian - avatar
+ 1
dat = input() x = input() vs = dat.count(x) res =int((vs/len(dat))*100) print(res)
26th Feb 2022, 12:52 AM
Liria
Liria - avatar
+ 1
More readable and effective string = input() match = input() res = "" for i in string: if match in i: res += i num = (len(res)/len(string))*100 print(int(num))
5th Sep 2022, 2:05 PM
Joel Justin
Joel Justin - avatar
0
can you put the coding for this question You are making a program to analyze text. Take the text as the first input and a letter as the second input, and output the frequency of that letter in the text as a whole percentage. Sample Input: hello l Sample Output: 40 The letter l appears 2 times in the text hello, which has 5 letters. So, the frequency would be (2/5)*100 = 40.
26th Feb 2021, 5:29 AM
Yuvaraja Keshani
Yuvaraja Keshani - avatar
0
Prakhar, damn, mate, seeing the simple int function at the end of your option I feel so dumb after solving this with the math.trunc method 😅 Well done!
12th Feb 2022, 9:41 PM
chalupa bazooka
chalupa bazooka - avatar
0
text = input() letter = input() analyzed = letter in text letter_count = text.count(letter) text_len = len(text) if analyzed: print(int((letter_count / text_len) * 100)) # my take..
8th Mar 2022, 9:36 AM
Semir A.
Semir A. - avatar
0
As a function. t = input() l = input() def frequency(txt,letter): tlen = int(len(t)) lc = t.count(l) freq = int((lc / tlen) * 100) return freq print(frequency(t,l))
29th Jul 2022, 2:37 PM
Landoperk
Landoperk - avatar
0
Short and Good! stri=input() L= input() print(int(stri.count(L)/len(stri)*100))
5th Oct 2022, 3:30 PM
Marcel Krättli
0
A little longer than other examples but it's works text = input() letter = input() txtLen= len(text) ltcount= 0 for i in text: if i == letter: ltcount+=1 frecuency = (ltcount / txtLen)*100 print(int(frecuency))
31st Oct 2022, 4:44 PM
Hebert Aranda