Answer:
Following are the code to this question:
file= open('book.txt') #open file
li= {} #define an empty list
for lines in file: # use for loop Split file data into words
d= lines.lower().strip(' !?').split() #define variable d that Add it to map
for val in d: #define loop to store data
if val not in li: #check value is not in list
li[val] = 0 #define list and assign value in 0
li[val] = li[val] + 1 #Sort the book data and add its value
m = sorted(li.items(),key = lambda x : -x[1]) #sorted value into the m variable
print(m[:10]) #print value
Output:
please find the attachment.
Explanation:
In the given python code first, we open the file "book.txt", in next line, an empty list is defined, that uses the for loop which can be described as follows:
- In the for loop is used, that reads the file data, and defines a variable "d", that stores the values into the map.
-
In the next line another loop is used, that check file values, if values are the same type so, it adds values and writes it.
- In the last line, m variable is used, that sorts the values and use the slicing to print its value.
Answer:
Software is a set of computer programs which makes computer work.
Tiered storage is an underlying principle of ILM (<span>information lifecycle management</span>). It is a storage networking method where data is stored on various types of media based on performance, availability and recovery requirements. For example, data intended for restoration in the event of data loss or corruption could be stored locally -- for fast recovery -- while data for regulatory purposes could be archived to lower cost disks.
Answer:
- jersey_dict = {}
-
- for i in range(5):
- j_num = int(input("Input Jersey's number (0-99): "))
- rating = int(input("Input rating (1 - 9): "))
- jersey_dict[j_num] = rating
-
- sorted_key = []
- for i in jersey_dict.keys():
- sorted_key.append(i)
-
- sorted_key.sort()
- for i in sorted_key:
- print(str(i) + ":" + str(jersey_dict[i]))
Explanation:
Firstly, define an empty dictionary (Line 1).
Next, use a for loop to prompt user to input five Jersey's number and rating and keep the input to the dictionary (Line 3-6). Next, create a list to hold the dictionary keys (Line 8-10). Use build in method, sort to arrange the keys in the list in ascending order (Line 12 ). At last, print the dictionary element by looping over the value in the sorted_key list (Line 14-15).