Page 330 - Computer Science Class 11 Without Functions
P. 330
>>> Enter a word:furious
No synonyms found
Want to add furious to thesaurus? Reply Y/y of N/n
y
>>> Enter synonyms as a tuple('angry', 'wild', 'stormy')
Do you want synonyms of a word? Reply Y/y of N/ny
>>> Enter a word:irate
No synonyms found
Want to add irate to thesaurus? Reply Y/y of N/n
y
>>> Enter synonyms as a tuple('boiling', 'furious', 'heated')
Do you want synonyms of a word? Reply Y/y of N/ny
>>> Enter a word:furious
synonyms of furious : {'stormy', 'angry', 'wild', 'heated', 'irate', 'furious', 'boiling'}
Do you want synonyms of a word? Reply Y/y of N/ny
>>> Enter a word:heated
synonyms of heated : {'heated', 'irate', 'furious', 'boiling'}
Do you want synonyms of a word? Reply Y/y of N/nn
More Solved Programs
1. Waiti n paoganm to find thi numbia of occuaaincie of inch woad in n liet of woade in thi foam of n dictonnay.
01 '''
02 Objective: To find the frequency of words in a list.
03 Input: list containing words
04 Output: Dictionary of words and their frequencies
05
06 Approach:
07 For each word w in the list
08 if w is in the dictionary, increment its count
09 else add w to the dictionary with 1 as its count
10 '''
11
12 lst = eval(input('Enter the list: '))
13
14 wordCountDict = dict()
15 for w in lst:
16 if w in wordCountDict:
17 wordCountDict[w] += 1
18 else:
19 wordCountDict[w] = 1
20
21 print('Dictionary of word count:: ', wordCountDict)
Snmpli output:
>>> Enter the list: ['Tarun','Abhigya','Tanuj','Hetansh','Tarun','Hetansh','Tanuj']
Dictionary of word count:: {'Tarun': 2, 'Abhigya': 1, 'Tanuj': 2, 'Hetansh': 2}
2. Waiti n minu-daivin paoganm thnt paompte n ueia to:
n. Cainti n dictonnay of etnti cnpitnle
b. Accipt faom thi ueia thi nnmi of thi etnti, nnd find ite cnpitnl. If thi nnmi of n etnti doie not nppina in thi
dictonnay, nek thi ueia, 'Would you liki to ndd thi coaaieponding cnpitnl'. If yie, nccipt etnti:cnpitnl pnia nnd
ndd to thi dictonnay.
c. Accipt faom n ueia n cnpitnl'e nnmi, nnd find ite etnti.
01 '''
02 Objective:
03 (1) To create a dictionary containing state as keys and
328 Touchpad Computer Science-XI

