100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Python Dictionary Practice Exam [HOTS Questions] $5.49   Add to cart

Exam (elaborations)

Python Dictionary Practice Exam [HOTS Questions]

 10 views  0 purchase
  • Course
  • Institution

A good brain teaser questions on dictionaries in python coding language,

Preview 1 out of 2  pages

  • November 4, 2021
  • 2
  • 2021/2022
  • Exam (elaborations)
  • Answers
avatar-seller
DICTIONARY - REVISION 5

1. Which of the following statements create a dictionary?
a) d = {}
b) d = {“john”:40, “peter”:45}
c) d = {40:”john”, 45:”peter”}
d) All of the mentioned

2. Select the correct way to print Emma’s age.
student = {1: {'name': 'Emma', 'age': '27', 'sex': 'Female'},2: {'name': 'Mike', 'age': '22',
'sex': 'Male'}}
a) student[0][1]
b) student[1][“age”]
c) student[0][“age”]

3. Which of the following will delete key_value pair for key="tiger" in dictionary?

dic={"lion":"wild","tiger":"wild","cat":"domestic","dog":"domestic"}

a) del dic["tiger"]
b) dic["tiger"].delete()
c) delete(dic.["tiger"])
d) del(dic.["tiger"])

4. Which of the following are true of Python dictionaries:

a) A dictionary can contain any object type except another dictionary.
b) All the keys in a dictionary must be of the same type.
c) Items are accessed by their position in a dictionary.
d) Dictionaries can be nested to any depth.
e) Dictionaries are mutable.
f) Dictionaries are accessed by key.

5. Write a function that creates a dictionary where the key is the number from 1 to n and
values have the message "Odd" or "Even" next to each number.
Example : If n=5 then the dictionary is
D={1:"Odd",2:"Even",3:"Odd"……}
6. Write a function that takes a dictionary student as parameter where the key is the name
of the students and the value is his percentage. This functions transfer the contents of
Dictionary Student to Dictionary Toppers if their percentage is above 90
7. Write a function that takes a string as the parameter and creates a dictionary that keeps
the track of the alphabets present in the string along with its count.
Example if the string is OCCURRENCE then the dictionary must be
{"O":1,"C":3,"U":1,"R":2,"E":2,"N":1}

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Stevendurby. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $5.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

72841 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$5.49
  • (0)
  Add to cart