Blog Archives
1 2

00: Python dynamic typing, module Vs package and Class Vs Object interview Q&As

Python is a very popular interpreted programming language with the features like strongly typed, dynamically typed, object oriented (i.e. polymorphism, inheritance & encapsulation) & supports functional programming. Also, introduces beginner terminologies like packages, modules, classes, objects, attributes, member variables, class variables, methods & functions.… Read more ...



01: Python Iterators, Generators & Decorators interview Q&As & Tutorial

Assumes that Python3 is installed as described in Getting started with Python.

1. Iterators

Iterators don’t compute the value of each item when instantiated. They only compute it when you ask for it. This is known as lazy evaluation.… Read more ...

Tags:

02: Python comprehensions interview Q&As & tutorial

Q. What is a comprehension?
A. Comprehensions are constructs that allow sequences to be built from other sequences. Python 2.0 introduced list comprehensions and Python 3.0 comes with dictionary, set and generator comprehensions.

List Comprehension

Set Comprehension

Given a list return a set.… Read more ...



03: Python context manager interview Q&As & tutorial

Q. What is a Python context manager?
A. The most common use of context managers is to properly manage resources. Context managers are a way of allocating and releasing some sort of resource exactly where you need it. The simplest example is file access:

Instead of:

The following code ensures that the file handle is closed, but very verbose.… Read more ...



04: In Python functions are objects tutorial

Q. Are functions objects in Python? A. Yes. In Python, a function is an object of type function. A function being an object means it is possible to pass a function object around as argument or as return value or to assign another name to the function object.… Read more ...



05: Python debugging tutorial

Q. How would you go about debugging Python code? A. Firstly, import pdb

Secondly, use “pdb.set_trace()” where ever you want the execution to pause as shown below with “addition.py” file.

Read more ...


06: Object introspection in Python tutorial

Q1. What is an Object introspection? A1. It is the ability to determine type & properties of objects at runtime. Everything in Python is an object. Every object in Python may have attributes and methods. Python dir(..) function The dir(..) function returns a sorted list of attributes and methods belonging…

Read more ...


07: Python dictionary tutorial

Q1. What is a dictionary in Python? A1. A dictionary is a general-purpose data structure for storing a group of objects as a set of keys and each key has a single associated value. A value can be a list or list within a list, numbers, etc.… Read more ...



08: Python Data modelling tutorial – Dunder or Magic Methods, Duck Typing & Protocols

Q1. What is Python data modelling? A1. Objects are Python’s abstraction for data. All data in a Python program is represented by objects or by relations between objects. As an intermediate to experienced Python developer always refer to the Python’s Data model documentation.… Read more ...



09: Python working with String tutorial

Strings in Python can be defined using either single or double quotations as they are functionally equivalent. In addition, it is possible to define multi-line strings using a triple-quote syntax: find() method finds the first occurrence of the specified value. method returns -1 if the value is not found.… Read more ...



10: Python working with collections tutorial

Python’s general purpose built-in containers are dict ( E.g. {‘a’:1, ‘b’:2, ‘c’:3} ), list ( E.g. [1,2,3,4] ), set ( E.g. {1,2,3,4 } ), and tuple ( E.g. (1,2,3,4) ). Following are specialised container datatypes providing alternatives. Counter

Output:

A counter is a dictionary-like object designed to keep…

Read more ...


11: Python *args and **kwargs tutorial

*args and **kwargs are mostly used in function definitions. *args and **kwargs allow you to pass a variable number of arguments to a function. It is not necessary to write *args or **kwargs. Only the * (asterisk) is necessary. So, you can even name them “*argv” and “**argv”.… Read more ...



12: Python enumerate vs zip interview Q&As and tutorial

Use of enumerate & zip are pythonic way of coding. Very common in Python job interviews & code reviews by your seniors or peers. enumerate to iterate over a list with an index The enumerate() function can be used to iterate over indices and items of a list.… Read more ...



13: Python working with files tutorial

Create a file to read from

Read from a file ‘r’ is for open file in read mode.… Read more ...



14: Python Closures, Partial functions and Currying tutorial

Closures In Python you have a closure when a nested function references a value in its enclosing scope as shown below. The inner function “inner_sum” references the enclosing function “outer_sum”‘s variable “num1”.

Read more ...


15: Python multithreading tutorial

Q. How will you make the following code multithreaded in Python?

Read more ...


16: Python multithreading producer/consumer & semaphores tutorial

Producer/Consumer in Python The Consumer and Producer threads run indefinitely while checking the status of the queue. The Producer thread is responsible for putting items into the queue if it is not full while the Consumer thread consumes items if there are any.… Read more ...



17: Python OOP and @property decorator tutorial

Members in a Python class are public by default All members in a Python class are public by default. Any member can be accessed from outside the class environment. Here is “person.py”

Read more ...


18: Python Abstract Base Classes (i.e. ABC) tutorial

Q. What is the difference between abstract class and interface in Python? A. Python doesn’t have a Java style formal interface, hence distinction between abstraction and interface doesn’t exist. Java uses interfaces because it doesn’t have multiple inheritance, but Python has multiple inheritance.… Read more ...



19: Python operator overloading tutorial

Q. What do you understand by Python being a dynamically, and strongly typed language? A. In the example below, it is important to understand that the type is not changing. Two objects are created – an int object first, and then a str object.… Read more ...



1 2
Don't be overwhelmed by the number of Q&As & tech stacks as nobody knows everything, and often key Q&As at the right moment makes a difference.

500+ Java Interview FAQs

Java & Big Data Tutorials

Top