Question
use python IDEL
Please highlight the answer
Problem 2 Dictionary. Read the following code and answer the next five questions about it. book1 = (Alice:arts, Bob: b
book 1 = {Alice: arts, Bob: botany. Clara: chemistryDasha: digital media} book 2 - (Eve: electronics, Fo
Question 6 1 pts Problem 2 Q1. What is the value of the variable condition 1 if the second print statement generates the foll
D Question 8 1 pts Problem 2 Q3. What is the value of the variable condition3 if the second print statement generates the fol
Question 9 1 pts Problem 2 Q4. How many items in the dictionary are printed by the first print statement? O 3 08 O1 ОО 09 07
Question 10 1 pts Problem 2 Q5. How many items in the dictionary are printed by the second print statement if condition 1 and
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer 6:

  • True

Answer 7:

  • False

Answer 8:

  • True

Answer 9:

  • 10

An explanation for answer number 6, 7, 8, and 9:

book1 = {
    "Alice": "arts",
    "Bob": "botany",
    "Clara": "chemistry",
    "Dasha": "digital media",
}

book2 = {
    "Eve": "electronics",
    "Forest": "hinances",
    "George": "geology",
    "Harry": "history",
    "Ivan": "Italian",
    "Joanna": "Japanese Arts",
}

mybook = {}

condition1 = True
condition2 = False
condition3 = True

for key in book1.keys():
    mybook[key] = book1.get(key)

mybook.update(book2)

# Here, mybook = {'Alice': 'arts', 'Bob': 'botany', 'Clara': 'chemistry', 'Dasha': 'digital media', 'Eve': 'electronics', 'Forest': 'hinances', 'George': 'geology', 'Harry': 'history', 'Ivan': 'Italian', 'Joanna': 'Japanese Arts'}
# Here, mybook has 10 items

# first print statement
print(mybook)

if condition1:      # condition1 is True i.e. the following block will be executed
    mybook["Bob"] = "biochemistry"
    mybook["Eve"] = "economics"

# Here, mybook = {'Alice': 'arts', 'Bob': 'biochemistry', 'Clara': 'chemistry', 'Dasha': 'digital media', 'Eve': 'economics', 'Forest': 'hinances', 'George': 'geology', 'Harry': 'history', 'Ivan': 'Italian', 'Joanna': 'Japanese Arts'}

for key in book1.keys():
    if mybook.get(key) == book1[key]:
        if condition2:  # condition2 is False i.e. the following block will NOT be executed
            del mybook[key]

# Here, mybook = {'Alice': 'arts', 'Bob': 'biochemistry', 'Clara': 'chemistry', 'Dasha': 'digital media', 'Eve': 'economics', 'Forest': 'hinances', 'George': 'geology', 'Harry': 'history', 'Ivan': 'Italian', 'Joanna': 'Japanese Arts'}

for key in book2.keys():
    if mybook.get(key) == book2[key]:
        if condition3:  # condition3 is True i.e. the following block will be executed
            del mybook[key]

# Here, mybook = {'Alice': 'arts', 'Bob': 'biochemistry', 'Clara': 'chemistry', 'Dasha': 'digital media', 'Eve': 'economics'}

# second print statement
print(mybook)

Answer 10:

  • 7

An explanation for answer number 10:

book1 = {
    "Alice": "arts",
    "Bob": "botany",
    "Clara": "chemistry",
    "Dasha": "digital media",
}

book2 = {
    "Eve": "electronics",
    "Forest": "hinances",
    "George": "geology",
    "Harry": "history",
    "Ivan": "Italian",
    "Joanna": "Japanese Arts",
}

mybook = {}

condition1 = True
condition2 = True
condition3 = False

for key in book1.keys():
    mybook[key] = book1.get(key)

mybook.update(book2)

# Here, mybook = {'Alice': 'arts', 'Bob': 'botany', 'Clara': 'chemistry', 'Dasha': 'digital media', 'Eve': 'electronics', 'Forest': 'hinances', 'George': 'geology', 'Harry': 'history', 'Ivan': 'Italian', 'Joanna': 'Japanese Arts'}

# first print statement
print(mybook)

if condition1:  # condition1 is True i.e. the following block will be executed
    mybook["Bob"] = "biochemistry"
    mybook["Eve"] = "economics"

# Here, mybook = {'Alice': 'arts', 'Bob': 'biochemistry', 'Clara': 'chemistry', 'Dasha': 'digital media', 'Eve': 'economics', 'Forest': 'hinances', 'George': 'geology', 'Harry': 'history', 'Ivan': 'Italian', 'Joanna': 'Japanese Arts'}

for key in book1.keys():
    if mybook.get(key) == book1[key]:
        if condition2:  # condition2 is True i.e. the following block will be executed
            del mybook[key]

# Here, mybook = {'Bob': 'biochemistry', 'Eve': 'economics', 'Forest': 'hinances', 'George': 'geology', 'Harry': 'history', 'Ivan': 'Italian', 'Joanna': 'Japanese Arts'}

for key in book2.keys():
    if mybook.get(key) == book2[key]:
        if condition3:  # condition3 is False i.e. the following block will NOT be executed
            del mybook[key]

# Here, mybook = {'Bob': 'biochemistry', 'Eve': 'economics', 'Forest': 'hinances', 'George': 'geology', 'Harry': 'history', 'Ivan': 'Italian', 'Joanna': 'Japanese Arts'}
# Here, mybook has 7 items

# second print statement
print(mybook)

FOR ANY HELP JUST DROP A COMMENT

Add a comment
Know the answer?
Add Answer to:
use python IDEL Please highlight the answer Problem 2 Dictionary. Read the following code and answer...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • use python IDEL Please highlight the answer Problem 1 Lists. Read the following code and answer...

    use python IDEL Please highlight the answer Problem 1 Lists. Read the following code and answer the next five questions about it. X = ? y=? z = ? zodiac = ["cow", "tiger", "rabbit", "dragon", "snake", "horse" "sheep", "monkey", "dog", "chicken", "pig", "rat"] first_group = zodiac[0:x] second_group = zodiac[x:y] third_group - zodiac[y:z] animals = [] for item in first_group: animals.append(item) for item in third_group: animals.append(item) for item in second group: animals.append(item) #first print statement print (animals) i = ? j...

  • use python IDEL Please highlight the answer Problem 3 Files. Read the following code and answer...

    use python IDEL Please highlight the answer Problem 3 Files. Read the following code and answer the next five questions about it. The contents of the files list 1.txt and list2.txt are the following (given side by side): list 1. txt content: list2.txt content 2 apples 2 apples 3 oranges 1 loaf of bread 2 eggs 2 eggs 1 cereal box # the program code starts here filename1 = "list 1.txt" filename2 - "list2.txt" filename3 - "listdiff.txt" with open (filename1,"r")...

  • use python IDEL Please highlight the answer Problem 1 Errors and Exceptions. There are two main...

    use python IDEL Please highlight the answer Problem 1 Errors and Exceptions. There are two main types of errors: syntax errors and runtime errors. Syntax errors are detected by the Python interpreter before the program execution during the parsing stage (parsing is a process, during which the Python interpreter analyzes the grammatical structure of the program). Runtime errors are errors in a program that are not detected by the Python interpreter during its parsing stage. They are further divided into...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT