Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

sexond half of question 7 below last answer of question 7 Question 1 2. 2 p Alice is new to python and is learning to

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
sexond half of question 7 below
image text in transcribed
last answer of question 7
image text in transcribed
Question 1 2. 2 p Alice is new to python and is learning to work with dictionaries. She has a key, k(type string) and she is trying to figure out if it occurs in the dictionary d. She is trying to write an if statement to do so. Which one(s) of the following statements will help Alice do so? Mark ALL those that are correct. if d in k.values(): if k in d. keys: if k in d: if din k. keys: if k in d. items: if din STY 411/quizzes/41382/take/questions/423441 Question 2 3 pt Alice is still working with dictionaries. She is trying to print all the keys that are present in the dictionary d. She experiments with different ways of doing so. Mark ALL of the following code snippets that correctly print all the keys in the dictionary d. fork in d. keys print(k) for kv in d. items: print) for k in d.volues: print) D York in di print) Previous Net 3 pts Alice is now trying to figure out which python types can be used as keys in a dictionary d. She experiments with different types using the following code snippets. Select the code snippets which will NOT give Alice an error Serience d. dicto k = set['key']) V = 'value' d[k] - V d-dict k-list(['key']) V = 'value' d[k] - d-dicto k-tuplec['key']) V-value d[k] - d-dicto "string - value d[k] - * * Question 4 3 pts RY Alice is now trying to figure out how to create dictionaries. She is attempting to create a dictionary d from a list 1. The keys need to be the Strings in the list whereas the values need to be the lengths of the corresponding strings. Which of the following code snippets will let her achieve this goal? Mark ALL that apply. at Experience ching 1 ['ant', 'tiger', 'elephant', 'bear'] d = dicto for kin 1. keys: d[K] - len(k) 1- ['ant', 'tiger, elephant'. 'bear] d-dicto for k in 1: d[K] - len(k) 1 - ['ont', 'tiger'. elephant', 'bear dk for k in 1] 2020-11. 1 - Cant'. 'tiger, elephant'. "bear d Ek Tenck) fork in 1) Next Question 5 Q tiger hrk) Fork 3 pts Alice is learning how to combine smaller lists to create bigger lists. She is given two lists 11 and 12 and she is trying to create a new list 13 that has all the elements of 11 followed by all the elements of 12. Also, she wants to preserve the lists 11 and 12. Which of the following code snippets will help her do so? Mark ALL the correct ones. nce 13 - 12.extend(11) 13 = list(11) 13. extend(12) 13 - 11 + 12 13 - 12.append(11) Next- Steam Previous 3 pts gul L2 Experience ing Alice is working with a really long list I. (It definitely has more than three elements in it) She is debugging her code and something seems to be going wrong for the last three elements in 1. As a result she is first trying to print out the last three elements in the list. She wants to print them out on separate lines, and in the order in which they occur in the list. Which of the following code snippets will help her do so? Mark ALL that apply. for i in range(len(1)) if len(1) - 13: print([1]) for i in range(len(1): If I > 3: print([1]) for 1 in range(len(1)): if len(1) - i 3: print([1]) 2020 for (in 10-3:1 print Steam QUE for in D:] printi) Question 7 3 pts Alice is working on a list that has repeated values. She is trying to figure out which elements appear only once in the list. So she writes a function once_only. Which ones of these implementations returns the elements that occur once only in the list? Mark ALL that apply. def once_only(l): unique_elements - list for i in len(1): if 1[i] not in 1: unique_elements.append(i) return unique dements def once_only(1): unique_elements = 0 for i in len(1): si - set(1) X - 1.popci) s2 = set(1) if len(52)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

2. How will you handle the situation?

Answered: 1 week ago

Question

3. Write a policy statement to address these issues.

Answered: 1 week ago