One Pager Cheat Sheet
- Python is an easy-to-read, open-source language that works on many operating systems, and has multiple applications ranging from website development to machine learning.
- Namespaces in Python are implemented as
dictionaries, providing an efficient data structure for mapping variables and their values to ensure no naming collisions occur. - Namespaces in Python are
containersthat hold objects and their names askeysandvaluesrespectively, with each function, module, or library having its own unique namespace. - Objects in Python have specific data types which determine what kinds of information they store and how they behave when used or manipulated.
- Python offers a wide variety of
data typesto handle data, includingnumeric,text, andBoolean. - Python
int,float, andcomplexdata types are used to represent numeric information. - Strings, defined using
' 'or" ", are atypeof text data that can include any number, word, sentence, or special character. - In Python,
booleandata is ofclass 'bool'and has either aTrueorFalsevalue. - We need to invoke or call a function to
executeit, which is usually represented by the function's name followed by parenthesis(). - The most commonly used built-in functions in
Pythonareprint(),len(),min(),max(),type(), andisinstance(). - The
print()function can be used to output strings, variables, and evenliteralvalues likeintegersandbooleans. - We can use the
len()function to find the length of astring,list,tuple, anddictionary. - The
min()function finds the minimum value of astring,list,tuple,dictionaryor multiple values passed as a parameter, resulting in-10when multiple values are passed. - The
max()function finds the maximum value of astring,list,tuple,dictionary, or of multiple values passed to it as parameters. - We can create different variables and check their types using the
type()function. - The
isinstance()function checks if a givenvalueis of a specificdata type. - List comprehensions are an efficient and effective way to
loopandfilterthrough data, requiring fewerlines of codeand often being more computationally efficient. - Dict and List Comprehensions are concise ways of creating new objects from existing ones, utilizing
keysandvaluesfor dictionaries andindicesandvaluesfor lists. ListComprehensions allow for quickly creating a newlistfrom an existing one using theexpressionfor eachvariablewithin thelistthat meets certainconditions.- An
operandis the object that an operator is applied to. - Yes, Python has multiple types of operators such as
comparison,identity,membership, andassignmentwhich can be used for different purposes. - An object is iterable when it implements the iterator protocol which consists of the
iter()andnext()methods for initializing the iterator and calling the next item, respectively, and raising theStopIterationexception when the final item is reached. Iteratorsencapsulatetheiterationprocess and areessentialto accessing objects in Python.- Yes, a generator is a
functionthat returns aniteratorand canyielda sequence of values without storing them in memory. - A generator is a special type of function marked by the
yieldkeyword, which returns aniteratorobject that can only be used with thefor-in loopornext()methods. - Object Oriented Programming (OOP)
relies heavilyon classes and objects, which serve as blueprints that describe the attributes, behaviors, and construction of a real-life object that can be created and have its methods and attributes accessed. OOPin Python utilizes traditional concepts such asclasses,objects,inheritance,encapsulation,polymorphism, andabstraction, just with a different syntax.- Inheritance, Encapsulation, Polymorphism, and Abstraction are all key principles of Object Oriented Programming that allow developers to create organized, extensible, and powerful software.
- Decorators can be used to add functionality to a function by being
wrapped aroundit. Decoratorsin Python can be used to add some feature or functionality to an existing function without altering it, likehanging a picture frameto enhance aroom.- We have used a
swipe_decorator()to add the functionality to ourdivide()function so that it swaps the values before they get divided iffirst < second. - Data Structures in Python are
Mutable,Ordered, allow forDuplicatesandDifferent Objectsand can be used for quickly retrieving relevant data with unique labels by using aDictionary, and the difference betweensorted()and.sort()is thatsorted()creates another list that is sorted whereas.sort()changes our original list. - A
Tupleis animmutabledata structure that does not allow for changes to be made after it is created. Slicingis a way of programatically accessing parts ofLists,Strings, andTuplesby using ObjectName[start:stop:step].- In slicing, the Stop index is
not inclusiveof the element at the specified index, which can be demonstrated by looking at the result ofmy_list[1:4]andmy_list[-1:-4:-1]. - This article explores the use of
Python(withimport pandasandnumpy) to solveGlassdoorinterview questions related to aggregating data and working with datasets.



