Computers and Technology, 20.03.2020 07:39 sundayrider101
Def readFile(filename): dict = {} with open(filename, 'r') as infile: lines = infile. readlines() for index in range(0, len(lines) - 1, 2): if lines[index].strip()=='':continue count = int(lines[index].strip()) name = lines[index + 1].strip() if count in dict. keys(): name_list = dict. get(count) name_list. append(name) name_list. sort() else: dict[count] = [name] print(count, name) return dict def output_keys(dict, filename): with open(filename,'w+') as outfile: for key in sorted(dict. keys()): outfile. write('{}: {}\n'.format(key,'; '.join(dict. get(key print('{}: {}\n'.format(key,';'.join(dict. get(key def output_titles(dict, filename): titles = [] for title in dict. values(): titles. extend(title) with open(filename,'w+') as outfile: for title in sorted(titles): outfile. write('{}\n'.format(title)) print(title) def main(): filename = input('Enter input file name: ') dict = readFile(filename) if dict is None: print('Error: Invalid file name provided: {}'.format(filename)) return print(dict) output_filename_1 ='output_keys. txt' output_filename_2 ='output_titles. txt' output_keys(dict, output_filename_1) output_titles(dict, output_filename_2
Answers: 1
Computers and Technology, 22.06.2019 11:20
The kurt vonnegut commencement speech, the neiman-marcus chocolate chip cookie recipe, and the get-well emails to the dying boy are examples of select one: a. social engineering b. hoax emails c. email viruses d. worms
Answers: 1
Computers and Technology, 22.06.2019 22:00
Competent nonverbal communication involves interacting with others in a manner that is appropriate for which of the following? select all that apply. situation task individuals
Answers: 3
Computers and Technology, 23.06.2019 07:10
If you want to import a picture into a dtp application, what must you do first? draw an image frame. import text. open the folder containing the file. select get image… from the windows menu.
Answers: 2
Computers and Technology, 25.06.2019 10:20
Write a program that lets the user play the game of rock, paper, scissors against the computer. the program should work as follows. 1. when the program begins, a random number in the range of 1 through 3 is generated. if the number is 1, then the computer has chosen rock. if the number is 2, then the computer has chosen paper. if the number is 3, then the computer has chosen scissors. (don’t display the computer’s choice yet.) 2. the user enters his or her choice of “rock”, “paper”, or “scissors” at the keyboard. (you can use a menu if you prefer.) 3. the computer’s choice is displayed. 4. a winner is selected according to the following rules: • if one player chooses rock and the other player chooses scissors, then rock wins. (the rock breaks the scissors.) • if one player chooses scissors and the other player chooses paper, then scissors wins. (scissors cuts paper.) • if one player chooses paper and the other player chooses rock, then paper wins. (paper wraps rock.) • if both players make the same choice, the game must be played again to determine the winner. be sure to divide the program into functions that perform each major task. include the code and the console output from running your program with test inputs in your report.
Answers: 3
Def readFile(filename): dict = {} with open(filename, 'r') as infile: lines = infile. readlines() fo...
Mathematics, 30.11.2020 19:00
Mathematics, 30.11.2020 19:00
English, 30.11.2020 19:00
Mathematics, 30.11.2020 19:00
Advanced Placement (AP), 30.11.2020 19:00
Health, 30.11.2020 19:00
History, 30.11.2020 19:00