• Slider Banner

    The Programming World

    Learn about top programming languages, tools and frameworks.

    Read more
  • Slider Banner

    Certification MCQ

    Practice for certification from 1000+ multiple choice questions.

    Read more
  • Slider Banner

    Prepare for Technical Interview

    Over 1 Million+ interview questions for different technical profiles.

    Read more

Is There a Way to Get a List of All the Keys in a Dictionary? If So, How Would You Do It?

To obtain a list of all the keys in a dictionary, we have to use function keys(). Check below example:

keys_list = []

for key in my_dict.keys():


Output: ['k1', 'k2', 'k3', 'k4']

In a List and in a Dictionary, What Are the Typical Characteristics of Elements?

Elements in lists maintain their ordering unless they are explicitly commanded to be re-ordered. They can be of any data type, they can all be the same, or they can be mixed. Elements in lists are always accessed through numeric, zero-based indices.

In a dictionary, each entry will have a key and a value, but the order will not be guaranteed. Elements in the dictionary can be accessed by using their key.

Lists can be used whenever you have a collection of items in an order. A dictionary can be used whenever you have a set of unique keys that map to values.

Write a Regular Expression using Python that confirms an Email Id is correct?

You can use Python Reg Expression Module "Re"

import re



What are negative indexes and why are they used?

To access an element from ordered sequences, we simply use the index of the element, which is the number of the position of that element. The index usually starts from 0, meaning that the first element has the index 0 and the second has 1, and so on.

When we use the index to access elements from the end of a list, it’s called reverse indexing. In reverse indexing, the indexing of elements start from the last element with the index number being ‘−1’. The second last element has the index ‘−2’, and so on. These indexes used in reverse indexing are called negative indexes.

What are functions in Python?

A function is a block of code which is executed only when it is called. To define a Python function, the def keyword is used. You can pass data, known as parameters, into a function. A function can return data as a result.


def my_function(name):
    print("Hi, Welcome to",name)

# Calling the function

Output: Hi, Welcome to ProgramsBuzz.

What is docstring in Python?

The docstrings are declared using """triple double quotes""" just below the class, method or function declaration. All functions should have a docstring.

The docstrings can be accessed using the __doc__ method of the object or using the help function.


def my_function(): 
    """This is my function documentation."""
print("Output Using __doc__:")
print("Using help:")


Subscribe to