Fullstack - Cafe - Tech Interview Plan: Q1: What Are The Built-In Types Available in Python?
Fullstack - Cafe - Tech Interview Plan: Q1: What Are The Built-In Types Available in Python?
Fullstack - Cafe - Tech Interview Plan: Q1: What Are The Built-In Types Available in Python?
Topics: Python
Answer:
Numbers
Strings
Tuples
List
Dictionaries
Sets
Topics: Python
Answer:
Python is an interpreted language. That means that, unlike languages like C and its variants, Python does
not need to be compiled before it is run. Other interpreted languages include PHP and Ruby.
Python is dynamically typed, this means that you don't need to state the types of variables when you
declare them or anything like that. You can do things like x=111 and then x="I'm a string" without error
Python is well suited to object orientated programming in that it allows the definition of classes along
with composition and inheritance. Python does not have access specifiers (like C++'s public , private ), the
justification for this point is given as "we are all adults here"
In Python, functions are first-class objects. This means that they can be assigned to variables, returned
from other functions and passed into functions. Classes are also first class objects
Writing Python code is quick but running it is often slower than compiled languages. Fortunately, Python
allows the inclusion of C based extensions so bottlenecks can be optimised away and often are. The numpy
package is a good example of this, it's really quite quick because a lot of the number crunching it does isn't
actually done by Python
Topics: Python
Answer:
You can’t, because strings are immutable. In most situations, you should simply construct a new string from the
various parts you want to assemble it from.
Page 1 of 5
FullStack.Cafe - Kill Your Tech Interview
Topics: Python
Answer:
Python is a dynamic-typed language. It means that you don’t need to mention the data type of variables
during their declaration.
Python supports object orientated programming as you can define classes along with the composition and
inheritance.
Functions in Python are like first-class objects. It suggests you can assign them to variables, return from
other methods and pass as arguments.
Developing using Python is quick but running it is often slower than compiled languages.
Python has several usages like web-based applications, test automation, data modeling, big data analytics
and much more.
Topics: Python
Answer:
PEP 8 is the latest Python coding standard, a set of coding recommendations. It guides to deliver more
readable Python code.
Topics: Python
Answer:
Python has the syntactical requirement that code blocks cannot be empty. Empty code blocks are however useful
in a variety of different contexts, for example if you are designing a new class with some methods that you don't
want to implement:
class MyClass(object):
def meth_a(self):
pass
def meth_b(self):
print "I'm meth_b"
If you were to leave out the pass, the code wouldn't run and you'll get an error:
Page 2 of 5
FullStack.Cafe - Kill Your Tech Interview
Topics: Python
Answer:
A lambda function is a small anonymous function. A lambda function can take any number of arguments, but
can only have one expression.
Consider:
x = lambda a : a + 10
print(x(5)) # Output: 15
Topics: Python
Answer:
Topics: Python
Answer:
The pickle module implements a fundamental, but powerful algorithm for serializing and de-serializing a Python
object structure.
Pickling - is the process whereby a Python object hierarchy is converted into a byte stream,
Unpickling - is the inverse operation, whereby a byte stream is converted back into an object hierarchy.
Topics: Python
Answer:
Python sequences can be index in positive and negative numbers. For positive index, 0 is the first index, 1 is the
second index and so forth. For negative index, (-1) is the last index and (-2) is the second last index and so forth.
Topics: Python
Answer:
Page 3 of 5
FullStack.Cafe - Kill Your Tech Interview
Global Variables: Variables declared outside a function or in global space are called global variables. These
variables can be accessed by any function in the program.
Local Variables: Any variable declared inside a function is known as a local variable. This variable is present
in the local space and not in the global space.
Q12: What are the rules for local and global variables in Python?
☆☆
Topics: Python
Answer:
In Python, variables that are only referenced inside a function are implicitly global. If a variable is assigned a
value anywhere within the function’s body, it’s assumed to be a local unless explicitly declared as global.
Requiring global for assigned variables provides a bar against unintended side-effects.
Topics: Python
Answer:
The two most common valid answers to this question (by no means intended as an exhaustive list) are:
The Global Interpreter Lock (GIL). CPython (the most common Python implementation) is not fully thread
safe. In order to support multi-threaded Python programs, CPython provides a global lock that must be held
by the current thread before it can safely access Python objects. As a result, no matter how many threads or
processors are present, only one thread is ever being executed at any given time. In comparison, it is worth
noting that the PyPy implementation discussed earlier in this article provides a stackless mode that supports
micro-threads for massive concurrency.
Execution speed. Python can be slower than compiled languages since it is interpreted. (Well, sort of. See our
earlier discussion on this topic.)
Topics: Python
Answer:
In Python, we do not have a switch-case statement. Here, you may write a switch function to use. Else, you may
use a set of if-elif-else statements. To implement a function for this, we may use a dictionary.
def switch_demo(argument):
switcher = {
1: "January",
2: "February",
3: "March",
4: "April",
5: "May",
6: "June",
7: "July",
8: "August",
9: "September",
10: "October",
Page 4 of 5
FullStack.Cafe - Kill Your Tech Interview
11: "November",
12: "December"
}
print switcher.get(argument, "Invalid month")
Topics: Python
Answer:
Flask is part of the micro-framework. Which means it will have little to no dependencies on external libraries. It
makes the framework light while there is little dependency to update and less security bugs.
Q16: Suppose lst is [2, 33, 222, 14, 25], What is lst[-1]? ☆☆
Topics: Python
Problem:
Solution:
It's 25 . Negative numbers mean that you count from the right instead of the left. So, lst[-1] refers to the last
element, lst[-2] is the second-last, and so on.
Topics: Python
Answer:
import some_module
print dir(some_module)
Topics: Python
Answer:
Descriptors were introduced to Python way back in version 2.2. They provide the developer with the ability to
add managed attributes to objects. The methods needed to create a descriptor are __get__ , __set__ and
__delete__ . If you define any of these methods, then you have created a descriptor.
Descriptors power a lot of the magic of Python’s internals. They are what make properties, methods and even the
super function work. They are also used to implement the new style classes that were also introduced in Python
2.2.
Page 5 of 5