answer.
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
Natali5045456
1 month 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:
Amiraneli [955]1 month ago
3 0

Answer:

Explanation:

When removing items from a dictionary, always specify the key in quotation marks.

For example: del country_capital['Prussia']

Failing to place it in quotes will cause the interpreter to view Prussia as a variable, resulting in an error saying that 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) #creating the dictionary from user input

del country_capital['Prussia'] #removing Prussia; failure to include quotes results in an error

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

if 'Prussia' in country_capital: #verifying the presence of Prussia in the dictionary

print('No.')

else:

print('Yes.')

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

if 'Spain' in country_capital: #checking if Spain is present in the dictionary

print('No.')

else:

print('Yes.')

print ('Togo deleted?', end=' ') #verifying the existence of Togo in country_capital

if 'Togo' in country_capital:

print('No.')

else:

print('Yes.')

Explanation:

You might be interested in
Write a class named Taxicab that has three **private** data members: one that holds the current x-coordinate, one that holds the
amid [867]

Response:

Refer to the explanation

Details:

class Taxicab():

def __init__(self, x, y):

self.x_coordinate = x

self.y_coordinate = y

self.odometer = 0

def get_x_coord(self):

return self.x_coordinate

def get_y_coord(self):

return self.y_coordinate

def get_odometer(self):

return self.odometer

def move_x(self, distance):

self.x_coordinate += distance

# increase the odometer with the absolute distance

self.odometer += abs(distance)

def move_y(self, distance):

self.y_coordinate += distance

# increase odometer with the absolute distance

self.odometer += abs(distance)

cab = Taxicab(5,-8)

cab.move_x(3)

cab.move_y(-4)

cab.move_x(-1)

print(cab.odometer) # will output 8 3+4+1 = 8

7 0
1 month ago
The Coins class was created to hold all your loose change, kind of like a piggy bank! For this exercise, you are going to simula
Amiraneli [955]

Answer:

Coins c1 = new Coins (4, 3, 2, 1);

c1.bankValue();

c1.addQuarter();

c1.addQuarter();

c1.addDime();

c1.addDime();

c1.addPenny();

c1.bankCount();

c1.bankValue();

Explanation:

8 0
4 days ago
Disk scheduling algorithms in operating systems consider only seek distances, because Select one: a. modern disks do not disclos
amid [867]

Response:

a. Current disks do not reveal the actual locations of logical blocks.

Clarification:

Modern disks incorporate scheduling algorithms within the disk drive itself. This presents challenges for operating systems trying to optimize rotational latency. All scheduling methods end up having to perform similarly due to potential constraints faced by the operating system. Disks are typically accessed in physical blocks. Modern technology applies more electronic control to the disk.

4 0
16 days ago
Suppose a linked list of 20 nodes. The middle node has a data –250. Write the pseudocode to replace the middle node of the linke
oksian1 [849]
The data for the middle node shows as –250.... Please outline the pseudocode to substitute the middle node in the linked list. Assume that the head pointer is designated as Head_ptr and the entry data for the new node is defined as Entry.
4 0
24 days ago
Read 2 more answers
Which type of testing is done when one of your existing functions stop working?
oksian1 [849]
The answer to the question is "alpha testing". Alpha testing aims to address issues like errors and debugging before software is launched. This testing is performed by developers when problems arise. In the software testing process, alpha testing occurs first, followed by beta testing. During alpha testing, developers check existing modules or functions that may have malfunctioned, ensuring any detected errors are addressed.
6 0
23 days ago
Other questions:
  • Until 2015, each new Roblox user automatically had one friend. What was he called?
    12·2 answers
  • Consider the following skeletal C program: void fun1(void); /* prototype */ void fun2(void); /* prototype */ void fun3(void); /*
    11·1 answer
  • Assume that the following variables have been properly declared and initialized.
    12·1 answer
  • Consider a one-way authentication technique based on asymmetric encryption: A --> B: IDA B --> A: R1 A --> B: E(PRa, R1
    13·1 answer
  • In a survey of 7200 T.V. viewers, 40% said they watch network news programs. Find the margin of error for this survey if we want
    6·1 answer
  • A wireless network does not benefit like a wired network does, when it comes to collision reduction. Which device reduces collis
    6·1 answer
  • Any software or program that comes in many forms and is designed to disrupt the normal operation of a computer by allowing an un
    13·1 answer
  • What term best describes the grammatical rules for writing proper code? paths syntax hyperlinks declarations
    7·2 answers
  • Explain what might happen if two stations are accidentally assigned the same hardware address?
    15·1 answer
  • During which stage does the central processing unit analyze the instruction and encode it in the form of a number, and then gene
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!