loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.01347526373050112","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IHJlcXVlc3RzCgojZmV3IGNvdW50ZXJzIHRvIGtlZXAgdHJhY2sgb2Ygd29yZCBjb3VudHMKY291bnRfbWVjY2FuPTAKY291bnRfbWVkaW5hbiA9IDAKCiN0aGVzZSB0d28gY291bnRlcnMgdG8ga2VlcCB0cmFjayBvZiB0b3RhbCBzdXJhaCBudW1iZXJzCm5fbWVra2k9MApuX21hZGFuaT0wCgojbG9vcCBvdmVyIHRoZSB0b3RhbCAxMTQgc3VyYWggb2YgUXVyYW4KZm9yIGkgaW4gcmFuZ2UoMSwxMTUpOgogICAgdXJsPSdodHRwOi8vYXBpLmFscXVyYW4uY2xvdWQvc3VyYWgvJytzdHIoaSkKICAgIGpzb25fZGF0YSA9IHJlcXVlc3RzLmdldCh1cmwpLmpzb24oKQogICAgaWYgKGpzb25fZGF0YVsnZGF0YSddWydyZXZlbGF0aW9uVHlwZSddID09ICdNZWNjYW4nKToKICAgICAgICBuX21la2tpKz0xCiAgICAgICAgdG90YWxfd29yZHMgPSAwCiAgICAgICAgZm9yIGF5YSBpbiBqc29uX2RhdGFbJ2RhdGEnXVsnYXlhaHMnXToKICAgICAgICAgICAgbGVuZ3RoID0gbGVuKGF5YVsndGV4dCddLnNwbGl0KCkpCiAgICAgICAgICAgIHRvdGFsX3dvcmRzKz0gbGVuZ3RoCiAgICAgICAgcHJpbnQoc3RyKGkpICsgJyBNZWNjYW4gLSBXb3JkczogJyArIHN0cih0b3RhbF93b3JkcykpCiAgICAgICAgY291bnRfbWVjY2FuKz10b3RhbF93b3JkcwogICAgZWxzZToKICAgICAgICBuX21hZGFuaSs9MQogICAgICAgIHRvdGFsX3dvcmRzID0gMAogICAgICAgIGZvciBheWEgaW4ganNvbl9kYXRhWydkYXRhJ11bJ2F5YWhzJ106CiAgICAgICAgICAgIGxlbmd0aCA9IGxlbihheWFbJ3RleHQnXS5zcGxpdCgpKQogICAgICAgICAgICB0b3RhbF93b3Jkcys9IGxlbmd0aAogICAgICAgIGNvdW50X21lZGluYW4rPXRvdGFsX3dvcmRzCiAgICAgICAgcHJpbnQoc3RyKGkpICsgJyBNZWRpbmFuIC0gV29yZHM6ICcgKyBzdHIodG90YWxfd29yZHMpKQoKcHJpbnQoJ1F1cmFuIGhhcyAxMTQgc3VyYWggYW1vbmcgdGhlbSAnKyBzdHIobl9tZWtraSkgKyAnIE1lY2NhbiBTdXJhaCwgYW5kICcrIHN0cihuX21hZGFuaSkgKyAnIE1hZGFuaScpCnRvdGFsX3dvcmRzID0gY291bnRfbWVjY2FuICsgY291bnRfbWVkaW5hbgpwcmludCgnVG90YWwgd29yZHMgaW4gUXVyYW46IHs6ZH0nLmZvcm1hdCh0b3RhbF93b3JkcykpCnBlcmNlbnRfbSA9IChjb3VudF9tZWNjYW4vdG90YWxfd29yZHMpKjEwMApwZXJjZW50X2QgPSAoY291bnRfbWVkaW5hbi90b3RhbF93b3JkcykqMTAwCnByaW50KCdNZWtraSB3b3JkczogezA6ZH0gW3sxOi4wZn0lXScuZm9ybWF0KGNvdW50X21lY2NhbiwgcGVyY2VudF9tKSkKcHJpbnQoJ01hZGFuaSB3b3JkczogezA6ZH0gW3sxOi4wZn0lXScuZm9ybWF0KGNvdW50X21lZGluYW4sIHBlcmNlbnRfZCkp"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import requests

#few counters to keep track of word counts
count_meccan=0
count_medinan = 0

#these two counters to keep track of total surah numbers
n_mekki=0
n_madani=0

#loop over the total 114 surah of Quran
for i in range(1,115):
    url='http://api.alquran.cloud/surah/'+str(i)
    json_data = requests.get(url).json()
    if (json_data['data']['revelationType'] == 'Meccan'):
        n_mekki+=1
        total_words = 0
        for aya in json_data['data']['ayahs']:
            length = len(aya['text'].split())
            total_words+= length
        print(str(i) + ' Meccan - Words: ' + str(total_words))
        count_meccan+=total_words
    else:
        n_madani+=1
        total_words = 0
        for aya in json_data['data']['ayahs']:
            length = len(aya['text'].split())
            total_words+= length
        count_medinan+=total_words
        print(str(i) + ' Medinan - Words: ' + str(total_words))

print('Quran has 114 surah among them '+ str(n_mekki) + ' Meccan Surah, and '+ str(n_madani) + ' Madani')
total_words = count_meccan + count_medinan
print('Total words in Quran: {:d}'.format(total_words))
percent_m = (count_meccan/total_words)*100
percent_d = (count_medinan/total_words)*100
print('Mekki words: {0:d} [{1:.0f}%]'.format(count_meccan, percent_m))
print('Madani words: {0:d} [{1:.0f}%]'.format(count_medinan, percent_d))