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
MariettaO [177]
2 years ago
8

In python please:

Computers and Technology
1 answer:
Vikki [24]2 years ago
3 0

Answer:

"

if 'marsupial' in dictionary:

   del dictionary['marsupial']

else:

   print("The key marsupial is not in the dictionary")

"

Explanation:

So you can use the keyword "in" to check if a certain key exists.

So the following code:

"

if key in object:

   # some code

"

will only run if the value of "key" is a key in the object dictionary.

So using this, we can check if the string "marsupial' exists in the dictionary.

"

if 'marsupial' in dictionary:

   # code

"

Since you never gave the variable name for the variable that references a dictionary, I'm just going to use the variable name "dictionary"

Anyways, to delete a key, there are two methods.

"

del dictionary[key]

dictionary.pop(key)

"

Both will raise the error "KeyError" if the key doesn't exist in the dictionary, although there is method with pop that causes an error to not be raised, but that isn[t necessary in this case, since you're using the if statement to check if it's in the dictionary first.

So I'll just use del dictionary[key] method here

"

if 'marsupial' in dictionary:

   del dictionary['marsupial']

else:

   print("The key marsupial is not in the dictionary")

"

The last part which I just added in the code is just an else statement which will only run if the key 'marsupial' is not in the dictionary.

You might be interested in
Let's say that you're the sole IT employee at your company. Your boss wants the company to migrate away from using the current,
EastWind [94]
IRC, Open IM Chat, and Email works
4 0
3 years ago
You have been asked to write a username validation program for a small website. The website has specific rules on what constitut
vazorg [7]

Answer:

var username;           // username entered by user

var charAny;            // text character identified in username

var anyNum = false;     // digit variable used to detect whether the username has one or not

var index;              // index loop variable

var BR = "<br />";      //break

var ES = "";            //space

// Display program requirements for the username requested

document.write("We'll begin helping you select a username" + BR);

document.write("Your username must have at least 8 characters," + BR);

document.write("   start with a letter, and contain at least 1 numeric character." + BR);

username = prompt("Please enter your username: ", ES);

// Check for length of username

while (username.length < 8) {

   document.write("Your username must be at least 8 characters long." + BR);

   username = prompt("Please enter your username: ", ES);

}

// Check that first character is a letter

// Substring function has three arguments: string, starting position, and ending position

charAny = username.substr(0, 1);

while (charAny !== isLetter()) {

   document.write("The first character of your username must be a letter." + BR);

   username = prompt("Please enter your username: ", ES);

}

// Check that there's at least one digit in the username

while (anyNum !== false) {

// Check each character, set anyNum to true if a digit

   for (index = 1; index < username.substr(index, index); index++) {

       anyNum = username.substr(index, index);

       if (isNumeric(charAny)) {

           anyNum = true;

       }

   }

   // If anyNum is false there were no numerics

   if (anyNum !== true) {

       document.write("Your username must include at least 1 digit." + BR);

       username = prompt("Please enter your username: ", ES);

   }

}

5 0
4 years ago
Original Problem statement from the Text: A retail company must file a monthly sales tax report listing the sales for the month
uysha [10]

Answer:

a

Explanation:

8 0
3 years ago
Which are examples of databases? Check all that apply.
Licemer1 [7]

Answer:

a set of stored information related to banking clients' transactions

Explanation:

7 0
3 years ago
Read 2 more answers
andy accidentally saved a file in the wrong folder. what is the quickest way to move the file? create a new file and save it in
Kruka [31]

take the improper folder to the proper place. but if that don't work if you have a copy of it then copy paste it to always be sure to have a backup

and sans said have this picture∵

                                                -

8 0
3 years ago
Read 2 more answers
Other questions:
  • Achieving a degree in computer forensics, information technology, or even information systems can provide a strong foundation in
    11·1 answer
  • Who can effectively use website authoring software?
    6·1 answer
  • What is information technology?
    12·1 answer
  • Write a Java program that will 1. Ask the user to type in a sentence, using a JOptionPane.showInputDialog(). 2. The program will
    10·1 answer
  • Which phrases/sentence correctly describe the use of bitmap images?
    8·1 answer
  • ith reference to McCall's quality modle , what are the three important aspects of a software product ?
    7·1 answer
  • Which statement is LEAST accurate? Select one: a. A common reason for ERP failure is that the ERP does not support one or more i
    14·1 answer
  • Write one paragraph: Do you feel comfortable giving out personal information online? Why or why not? Is there a limit to what yo
    8·1 answer
  • What is draft pls help me​
    15·2 answers
  • A _ is the acknowledgment of a potential noncomformity, or an opinion regarding an issue that is not covered by a standard
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!