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
Murljashka [212]
4 years ago
13

Delete Prussia from country_capital. Sample output with input: 'Spain:Madrid,Togo:Lome,Prussia: Konigsberg' Prussia deleted? Yes

. Spain deleted? No. Togo deleted? No.
Computers and Technology
1 answer:
7nadin3 [17]4 years ago
3 0

Answer:

Explanation:

When deleting anything from dictionary always mention the key value in quotes .

Ex: del country_capital['Prussia']

if we don't mention it in quotes it will consider that Prussia as variable and gives the error Prussia is not defined.

Code:

user_input=input("") #taking input from user

entries=user_input.split(',')    

country_capital=dict(pair.split(':') for pair in entries) #making the input as dictionary

del country_capital['Prussia'] #deleting Prussia here if we don't mention the value in quotes it will give error

print('Prussia deleted?', end=' ')

if 'Prussia' in country_capital: #checking Prussia is in country_capital or not

print('No.')

else:

print('Yes.')

print ('Spain deleted?', end=' ')    

if 'Spain' in country_capital: #check Spain is in Country_capital or not

print('No.')

else:

print('Yes.')

print ('Togo deleted?', end=' ') #checking Togo is in country_capital or not

if 'Togo' in country_capital:

print('No.')

else:

print('Yes.')

Explanation:

You might be interested in
Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 5
omeli [17]

Answer:

The Following are the code to this question:

def cost(miles, milesPerGallon, dollarsPerGallon):##defining a method cost that accepts three parameter

   return miles / milesPerGallon * dollarsPerGallon# calculate cost and return it value  

milesPerGallon = float(input('Enter miles/Gallon value: '))#defining variable milesPerGallon for user input  

dollarsPerGallon = float(input('Enter dollars/ Gallon value: '))#defining variable dollarsPerGallon for user input

print('{:.5f}'.format(cost(10, milesPerGallon, dollarsPerGallon)))#call method and print its value

print('{:.5f}'.format(cost(50, milesPerGallon, dollarsPerGallon)))#call method and print its value

print('{:.3f}'.format(cost(400, milesPerGallon, dollarsPerGallon)))#call method and print its value

Output:

Enter miles/Gallon value: 20.0

Enter dollars/ Gallon value: 3.1599

1.57995

7.89975

63.198

Explanation:

In the above-given code, a method "cost" is defined, that accepts three value "miles, milesPerGallon, and dollarsPerGallon" in its parameter, and use the return keyword for calculating and return its value.

In the next step, two variable "milesPerGallon, and dollarsPerGallon" is declared, that use the input method with float keyword for input floating-point value.

After input value, it uses a print method with different miles values, which are "10,50, and 400", and input value to pass in cost method to call and print its return value.

5 0
3 years ago
I can’t wait Till Miya’s anniversary skin To be released on september 21st
dezoksy [38]

Answer:

no u

Explanation:

no need

3 0
3 years ago
How do i switch my level to high school on brainly
Bumek [7]

Edit your profile, click preferences, and then there should be a drop down that has your level on it which you can change.

7 0
3 years ago
Read 2 more answers
Beth’s multimedia business specializes in sound integration and editing. A New project requires video editing and the creation o
ANEK [815]

Answer:

A. Adobe illustrator

Explanation:

4 0
4 years ago
How many comparisons will be made to find 8 in this list using a linear search?
Kobotan [32]

Answer:

4

Explanation:

4

6 0
3 years ago
Other questions:
  • Develop a program that will calculate the area and perimeter of a rectangle. The length and width can be given as constant.(LENG
    8·1 answer
  • Write a statement that toggles the value of the bool variable onoffswitch. that is, if onoffswitch is false , its value is chang
    10·1 answer
  • These items describe guidelines for the effective use of presentation graphics. Graphics should be large enough to be seen by th
    9·1 answer
  • How do you write the slope-intercept form?
    5·1 answer
  • Which of the following statements about email is true?
    5·1 answer
  • DEFINE WHAT COPYRIGHT?
    14·2 answers
  • Whats wrong with my code for .addEventListener
    11·1 answer
  • To combine concepts or ideas into a whole is called
    11·2 answers
  • In French class, Blue puts on a visor and the environment changes to that of a café in Paris. Which of the following terms descr
    12·2 answers
  • Which three techniques are used in this photo
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!