23 odpowiedzi
+ 20
Hope you're asking about this one :)
stri=input()
L= input()
print(int(stri.count(L)/len(stri)*100))
+ 11
LETTER FREQUENCY
word=input()
letter=input()
n=len(word)
per=((word.count(letter)/n)*100)
print(int(per))
+ 6
Please share your attempt for your project as well as add description details to your question.
+ 6
txt = input()
lter = input()
co = 0
for i in txt:
if i == lter:
co +=1
print(int(co/len(txt)*100))
+ 4
Thank you very much, My last line was wrong
+ 3
Thanks a lot!
+ 3
letter frequency:
text = input()
letter = input()
counter = text.count(letter)
frequency = int ((counter/len(text)) * 100)
print(frequency)
+ 2
¿¿¿¿Just give a hint or something????
+ 2
text = input()
letter = input()
x = text.count(letter)
y = len(text)
percentage = (x*100)/y
print(int(percentage))
+ 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))
+ 2
#simple solution
w = input()
l =input()
n=len(w)
p =((w.count(l)/n)*100)
print(int(p))
+ 1
first = input()
second = input()
suum = first.count(second)
div = len(first)
total = (suum / div) * 100
print(int(total))
+ 1
dat = input()
x = input()
vs = dat.count(x)
res =int((vs/len(dat))*100)
print(res)
+ 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))
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.
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!
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..
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))
0
Short and Good!
stri=input()
L= input()
print(int(stri.count(L)/len(stri)*100))
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))