1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mr_godi [17]
3 years ago
5

Write a program that reads the data from rawdata_2004.txt into a dictionary whose keys are country names and whose values are pe

r capita incomes. Then the program should prompt the user to enter country names and print the corresponding values. Stop when the user enters quit.
Computers and Technology
1 answer:
san4es73 [151]3 years ago
7 0

Answer:

import re

def country_capita():

   #opens file

   file=open("inputfile.txt", "r")

   dictionary=dict()

   #reads line by line

   for line in file.readlines():

       # substitutes for multiple space a single space

       line = re.sub(r"[\s]{2, }", ' ', line)

       list=[]

       #splits line on space

       list=line.split(" ")

       #put into dictionary

       dictionary[list[1]]=list[2]

#   get input

   while True:

       choice=input("Enter the country name or quit to exit: ")

       if choice=="quit":

           break

       elif choice in dictionary.keys():

           print(dictionary[choice])

       else:

           print("Invalid Country")

country_capita()

Explanation:

Using python to code this program. First we, (line 1) import the re module which offers us a set of functions that allows us to search a string for a match. ((line 2) Next we define a function country_capita() that will open rawdata_2004.txt, read the information within line by line and create a dictionary list. The we create a while loop with conditional statements that prompt the user to enter country names, print the corresponding values and stops when the user enters quit.

You might be interested in
A _____ model is one that is automatically adjusted based on changing relationships among variables.
BabaBlast [244]

Answer: dynamically modified model

Explanation:

7 0
2 years ago
Match the following:
Bogdan [553]

Answer:

  1. Operating System.
  2. Laptop.
  3. Convertible computer.
  4. Peripheral.
  5. Desktop Computer.

Explanation:

Operating system is a software that manages the hardware and the software in the system and provides the interface between machine and the user.

Laptops are the portable computing devices which you can carry with you.

Convertible computer have a keyboard that is detachable and can be converted into a tablet.

Peripherals are devices which we can attach to the computer.

Desktop computer is a computing device that not portable at all.

3 0
3 years ago
A technician needs to be prepared to launch programs even when utility windows or the Windows desktop cannot load. What is the p
ololo11 [35]

Answer:

Msinfo32.exe, cmd

Explanation:

The msinfo.exe is a tool that gathers information concerning your computer system and displays a comprehensive view of your system components, hardware, and software environment, that can later be use to diagnose computer issues.

Command Prompt is an interpreter application for command line which is available in nearly all Windows operating systems. It is utilized for executing entered commands.

6 0
3 years ago
1. Read What You Need to Know closely and watch the Five Components of Fitness video
Maslowich

Answer:

hi sorry

Explanation:

I

3 0
3 years ago
The ASE certification system uses _______ testing and an evaluation of on-the-job experience to confirm that a technician meets
erma4kov [3.2K]
 MY answer would be A or C .Hope this helped
7 0
3 years ago
Read 2 more answers
Other questions:
  • Ally made the net below to find the surface area of a box she was designing. The box measures 12 centimeters long by 9 centimete
    7·1 answer
  • Objects of the calculator class require no additional information when created. define an object named calc, of type calculator.
    14·2 answers
  • A method that receives a two-dimensional array uses two ____ pairs following the data type in the parameter list of the method h
    11·1 answer
  • Downloading files is safe for most types of files except Select one: a. documents. b. pictures. c. executable files. d. music fi
    7·1 answer
  • Which slide elements must claire use to enhance her presentation?
    10·2 answers
  • ________ is the process the compiler uses to divide your source code into meaningful portions; the message means that the compil
    7·1 answer
  • How many bits does it take to store a 3-minute song using an audio encoding method that samples at the rate of 40,000 bits/secon
    12·1 answer
  • In photoshop what should you consider when determining a projects purpose and objectives?
    15·1 answer
  • Choose a problem that lends to an implementation that uses dynamic programming. Clearly state the problem and then provide high-
    10·1 answer
  • Which item can be added to Outlook messages, like a Word document or PowerPoint presentation, that takes standard bulleted lists
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!