Python Technical Interview – An Experience

As a freelancer one of the things that comes with getting a project/job is handling technical interviews. I have so far managed to convince the client with a work sample, test project …etc., This is literally the first time I sat for a full technical interview. And it did teach a few lessons. Let me document it for future use.

It started off with the basic of the language:

1. What is the difference between an iterable and an iterator?

Vincent Driessen provides a clear explanation of the difference with the examples here https://nvie.com/posts/iterators-vs-generators/

As an aside, he has a number of posts which are really great like his Git workflow model that I have used in my projects. Bookmark it

2. What is a Context Manager? What is its purpose? How is it different from a try…finally block? Why would you use one over another?

Context Manager are functions/classes that allow us to allocate and release resources as required. Used with the with keyword in code.

The difference between context manager and try..finally block is explained in technical detail here: https://stackoverflow.com/questions/26096435/is-python-with-statement-exactly-equivalent-to-a-try-except-finally-bloc

But a simpler more practical difference is given by Dan Bader: https://dbader.org/blog/python-context-managers-and-with-statement

3. Can you tell me some advantages of Python over other languages?

I rambled something like, it is is easier to read and write. The file structure (I should have said modules/packages) is great. Even modern iterations of Javascript are copying the import from syntax. Native implementation of a lot of things in standard library…etc.,et.,

But the thing my interviewer was looking for were the words “automatic garbage collection” because the next question was

4. How does Python handle memory?

Python has automated memory management and garbage collection.That is why we never worry about how much memory we are allocating like C’s malloc `calloc functions.

5. Do you know how Python does that? Do you know about GIL?

sheepish smiles and saying no’s ensued. I ran into an issue a few months back, I think maybe with a DB connection issue or something which led me on a rabbit hole that ended with GIL. I should have learnt it that day.

Anyway, here is the article about Python’s memory management. https://realpython.com/python-memory-management/

6. Have you worked on projects involving multi-threading? What do you know about multi-threading?

I hadn’t. Someday maybe I will.

7. Can you explain in detail the steps involved in a form submit to response cycle in detail?

https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Sending_and_retrieving_form_data

8. How does the browser know where your server is when the information is submitted to a particular URL?

DNS servers – IP resolution

9. The server sends back text as a string how do you see colorful information in browser?

The text is converted into DOM elements which are rendered by the browsers rendering engine.

10. If a browser is showing unreadable character and question marks instead of displaying the information what could be the reason?

Document Encoding mismatch. The server might send the data encoded in Unicode UTF-8 and the browser might be decoding it as ASCII or LATIN-1 resulting in weird characters and question marks being rendered in the browser.

11. You said Unicode and UTF-8 what is the difference?

Unicode is the term used to describe the character set. If it is encoded with 8 bits it is called UTF-8, if encoded with 16 bits it is called UTF-16 etc.,

For deep dive into Unicode (a must): https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/

12. What kind of request does the browser make to a server? And what are the types of requests that can be made?

Browsers make a HTTP requests. The types are GET, POST, PUT, DELETE, HEAD, OPTIONS ..etc., (I think I said UPDATE instead of PUT, silly)

13. What is the difference between `==` and `===` in JavaScript?

StackOverflow: https://stackoverflow.com/questions/523643/difference-between-and-in-javascript

Some other questions, that were asked:
1. Do you know Docker? Have you used AWS?
2. Do you know Data Base schema design?
3. You have a SQL query that takes a long time to execute. How would you begin to make it faster? Do you know about Query optimisation and execution plans?

Sensible Test Data

I am currently working on a project called Peer Feedback, where we are trying to build a nice peer feedback system for college students. We use Canvas Learning Management System (CanvasLMS) API as the data source for our application. All data about the students, courses, assignments, submissions are all fetched from CanvasLMS. The application is written in Python Flask.

Current Setup

We are mostly getting data from API, realying it to frontend or storing it in the DB. So most of our testing is just mocking network calls and asserting response codes. There are only a few functions that contain original logic. So our test suite is focused on those functions and endpoints for the most part.

We recently ran into a situation where we needed to test something that involved the fetching and filtering data from API and retriving data from DB based on the result.

Faker Library and issues

The problem we ran into is, we can’t test the function without first initalizing the database. The code we had for initializing the CanvaLMS used the Faker library, which provides nice fake data to create real world feel for us. But it came with its own set of problems:

Painful Manual Testing

While we had the feel of testing realworld information, it came with real world problems. For e.g., I cannot log in as a user without first looking up the username in the output generated during initialization. So I had to maintian a postit on my desktop, use search functionality to find the user I want to test and copy his email and login with it.

sensible_test_data_1

Inconsistency across test cycles

When we write our tests, there is no assurity that we could reference a particular user in the test with the id and expect the parameters like email or user name to match. With the test data being generated with different fake data, any referencing or associaation of values held true only for that cycle. For e.g, a function called get_user_by_email couldn’t be tested because we didn’t know what to expect in the resulting user object.

Complex Test Suite

To compensate for the inconsistency in the data across cycles, we increased the complexity of the test suite, we saved test data in JSON files and used it for validation. It became a multi step process and almost an application on its own. For e.g, the get_user_by_email function would first initialize the DB, then read a json file containing the test data and get a user with email and validate the function, then find the user without an email and validate it throws the right error, find the user with a malformed email… you get the idea. The test function itself not had enough logic warranting a test of test suites.

Realworld problems

With the realworld like data came the realworld problems. The emails generated by faker are not really fake. There is a high chance a number of them are used by real people. So guess what would have happened when we decided to test our email program 🙂

Sensible Test Data

We finally are switching to a more sensible test data for our testing. We are dropping the faker data for user generation, and shifiting to the sequencial user generation system with usernames user001 and emails user001@example.edu. This solves the above mentioned issues:

  1. Now I can login without having to first look it up in a table. All I need to do is append a integer to the word user
  2. I can be sure that user001 would have the email user001@example.edu and that these associations will be consistent across test cycles.
  3. I no longer have to read a JSON file to get a user object and test related information. I can simply pick one using the userXXX template, reducing complexity of the test suite.
  4. And we won’t be getting emails for random people asking us to remove them from mailing lists and probably we are saving ourselves being blacklisted as a spam domain.

Conclusion

Faker provided us with data which helped us test a number of things in the frontend, like the different length in names, multi part names, unique names for testing filtering and searching etc., while also added a set of problems that makes our work difficult and slow.

Our solution to having a sensible dataset for testing is plain numerically sequenced dataset.

Update

Using the generic name tags like user was still causing friction as we have multiple roles like teacher, TAs, students …etc., So I improved it further by creating users like student0000, ta000, `teacher00“.

Thattachu – Open Source Typing Tutor

Typing tutor is a known ancient domain to work on. There are a number of places online/offline, tangible/intangible places to learn typing. But Srikanth (@logic) stumbled on a peculiar problem when worked for the Wikimedia Language Engineering team. The new age Indic input methods involved in computers seem to have no place to learn how to type on them. The only way seems to be – have a visual reference for the layout and begin typing one key at a time. This might be the most inefficient method of learning to input information. So what do we do?

Enter Thattachu

Thattachu is an open source typing tutor. It is built using the tool that Wikimedia Language Engineering Team have developed called jQuery IME. jquery.ime currently supports 62 languages and 150+ input methods. This is a JavaScript library which can be used on any web page. So we (I & Srikanth) set out to build a generic typing tutor which could employ any of the 62 languages or 150+ input methods. The project was conceived in May 2014 and was worked on only by May 2015 as I was busy with my Teach For India Fellowship. Thattachu borrows its tutor style from GNU Typist or gTypist which I used to learn touch typing in English.

Interface

Thattachu has three pages:

  1. Home page – A welcome page for those visiting the site and explaining what it is about.Thattachu_page1
  2. Course Selector – A place where you choose the course to learn. You select the language and the input method you want to learn and it lists the available courses.Thattachu_page2
  3. Workbench – A place where you practice typing. When you select a course in the Course Selector, the workbench loads with the course you selected and you can begin typing with the input method you chose. It remembers your most recent course and lesson so you can continue from where left it the previous session.Thattachu_page3

Course Structure

Each language has a set of input methods – each input method has a set of courses. The courses are classified based on their difficulty as “Beginner”, “Intermediate” and “Expert”. Each course has a set of lessons to complete and and each lesson is a collection of lines that have to be typed.

thattachu_courses

Thattachu Asiriyar

Creating the tool is the easier part of a content dependent system. The real work is generating the content that the tool can be used with. That way we faced the challenge of creating course.JSON files required for the tool. Hence a user friendly tool Thattachu Asiriyar was born.

Thattachu Asiriyar lets anyone author a course and generate a course file. If you want to author courses, go to Thattachu Asiriyar create the course file and mail it to
arun [at] arunmozhi [dot] in -mentioning “Thattachu course” in the subject.

Github savvy authors

Or if you have a Github account and know about pull requests. Kindly

  1. Fork the Thattachu repohttps://ghbtns.com/github-btn.html?user=tecoholic&repo=thattachu&type=fork&count=true
  2. Put the course file into the data/language_code folder
  3. Update the courselist.json in your folder with the metadata and the filename
  4. Send me a pull request.
  5. Feel awesome for helping the humanity learn typing

Developers

Here are a few points for those interested in the code or those who think they can improve Thattachu.

  • Thattachu is a web application written in HTML and JavaScript (AngularJS).
  • It is a completely static site with all the information stored as JSON files and served by XHR requests when requested by the Angular $http.
  • For input jQuery.ime is used.
  • It is a completely static site and can be hosted in any web server.
  • It uses localStorage of the user to track last worked on course and load it when the user opens the page next time.

Getting ready for planet CODE

With the end of TeachForIndia Fellowship around the corner, I am contemplating on jumping into the programming world. So here is a checklist of things that I am going to put up in place and document it along the way.

Get a decent mail ID

Though not strictly related to planet code, I wanted to have a decent email id. The one I used ~~aruntheguy at gmail~~ was created when I was 15 and not so professional. Hence I have moved the mail to arunmozhi.in.

Creating a online presence

These days online presence is mostly Social Media. I deleted my Facebook account and have only Twitter, but that alone isn’t sufficient.

So,
Moved blog from static-site Pelican back to wordpress for easy theming and maintanence
Created a home page where I can showcase stuff

Customer Research

Making use of a skillset is all about selling it. So what do the buyers look for? Being a follower of Coding Horror I started of with his post on How to hire a programmer.

Here are the things I learnt:
1. Know to really write a program – I pass
2. Should have a portfolio – Need to create a portfolio page
3. Be culturally fit for the role – Depends on the company
4. Answer computer science theoritical/tricky/nerdy qustions – Well you can’t really prepare for them, can you? May be the theory part, but again when was the last time I thought about hash tables, 3rd year of my college?
5. Expect an audition project or a real world problem to solve.
6. Pitch in front of small group – have mixed feelings about this. But good to know this might be coming.

1 is done, 2 requires some work, 3 can’t really be worked on, 4 is subjective on how we look at it, solving puzzles and learning nerdy jokes is not the point, it shows the recruiter how we approach a problem and how much passionate about programming is a person. I will leave them at that. Finally, the points 5 and 6 are subjective to personal preference and circumstances as outlined in the comments by various people. I am sort of going to forget them for now.

Product preparation

I am the product, in case you are wondering. The article cited above and others linked in that article give a general idea about the product.
With that in mind, and my long time personal goals, here is the list of things I have in mind to do:

  1. Learn touch-typing!! Yeah, I am a pecker – albeit a fast one. – Done
  2. Learn Vim to the extent I am not going into v mode everytime to delete a set of words. – Ever learning
  3. Get core commit rights for QGIS – its time to work on itCouldn’t fit in time.
  4. Create a Portfolio/Resume/HireMe page
  5. Learn some tools of trade:
    • Plain text manipulations – Regex
    • Shell scripting
    • Code Editor – Vim
    • Version Control – Git + Github
    • Debugging Tools
    • Unit Testing Frameworks
  6. …….

I guess I will add more to the list as I set the goals. For now this should keep me focused.

Session Signup – A Coding Project

Update: This project never took off from the drawing board.

I work for Teach For India as a Fellow now and we have Teacher Development workshops, City Conferences once in a month where there are multiple sessions which provide technical training on multiple things at the same time. So we have a system where the Fellow chooses the sessions he wishes to attend. Presently here is how the session signup process works.
Signup_Automation

I am thinking of automating the red circle region by writing a web application that can run on Google App Engine. Since our organization uses Google Apps account for its IT needs. I think the integration could be more easily done with almost no cost.

Update 1:

Initiated the project using the Google App Engine. Signed up for a 60 Day & $300 credit Free trail from Google Cloud Services. – December 2,2014

The Setup

Continuing from the previous post, let me write down everything that defined my work setup.

The Curriculum

This is where the fun starts. I worked with two different curriculum throughout the year. The school wanted me to teach the mandated Samacheer syllabus and the organisation that I work for wanted me to teach to the Common Core Standards. The Samacheer part contained the Social, Science and the “English as a subject” subjects to be taught, the organisation gave me Mathematics  and “English as a standard” subjects to teach. It is actually painful to be a teacher and teach language either as a subject or as a set of standards. More on that separately sometime later (which is almost never).

The Red Ink

There were 37 notebooks for each (3) Samacheer subject to be checked and corrected 3-5 times in every term. Each term itself is about 3 or 4 months. And there where 2 mid-term term tests and 1 end of term test for each term. For the organization’s part, we were supposed to conduct Unit Assessments, which is one in 6 weeks, Weekly assessments and if possible Daily Assessments. I just did the Unit Assessments. Tried Weekly assessments but dropped it after a couple of weeks, it was getting out of hands. English made up for it, by making me correct a set of at least 10 questions every alternate day. I remember sitting, standing, sleeping, walking and even jumping on/off trains with my bag on the shoulder, papers on the left hand and red pen on the right.

The Sessions

The organisation’s way of making sure we are fully equipped to handle everything in the classroom. It was usually planned in the evenings after school when we are in our lowest glucose levels and looking out for a corner to curl. The sessions did make a lot of sense to the people who were organizing them. They were usually about how to teach, how to handle kids, how to understand a particular area in order to deliver it the way it is supposed to be. But one thing no one seemed to care/understand/grasp was there was no single way to do stuff.

The Printer

Canon LBP2900. One trademark of being a TFI fellow is we print more paper for each kid than what government or the school would. Having a laser printer really does help. One can be free of the timing restrictions imposed by the Xerox shops and save a lot more money. I printed about 8000-9000 pages in the last 4 months alone. 1500 rupees for all that paper and 400 rupees for the toner and the immense flexibility of being able to print whatever and whenever.

The Travel

The travel was two/three legged. I usually started off with short bus ride 5E/23C/49 from Adyar depot to Madhya Kailash, took a train from Kasthuribai Nagar station to the Beach Station, and then finally took 44C from Beach Station to the Power House stop. Sometimes the 5E-Train combo was replaced by the 21H/PP19 from Adyar Depot to Parry’s Corner. Initially used 6D from the backside of Adyar Depot, but extra 300m walking and having no alternate buses made me switch to other options. One thing good about the train travel is I always found space to sit and even work on the laptop if required. Having a monthly season ticket for just 105 rupees was another boon. Never had to worry about tickets/queues and oversleeping during return journeys.

 

These define the physical boundaries of how I worked in the past one year. But how did I actually work? What was “The process”?

After 1 Year

Sitting on the rope cot in my grandparent’s home near Kodumudi, Erode, listening to Rainbow FM staring at the laptop screen is where I am, when I write this. Very far away from anything related to school, students and teaching – Physically. Teaching is a job that grows on you and you grow over until both becomes indistinguishable from one another. Looking back after one year of being the worst possible teacher in my own rating, I think I have also become the worst possible blog writer in many people’s rating.

The first blog post was written well before I became a teacher and it turns out it has been 364 days (so not 1 year really). I have written about 5 posts excluding “Hello”, of which only 3 during the Fellowship. This points to the very obvious fact about the Fellowship itself – it is hectic and mad at the same time. It also points to the fact that I never took time to unload myself as often as I should have done.

So, I am going to write down a summary of what all I can possibly remember in a subjective manner. This blog was not meant to be subjective in any way, it was supposed to be a place where things will be recorded as is without analysis or perspective. But with such a big backlog of about a year, I doubt I can write anything objective as-is here.

The Setup

School

ECI Matriculation Higher Secondary School, Tondiarpet – that is the name of the school where I was placed as a Teach For India Fellow to teach a set of 37 students in 4th grade. The school is run by a trust run the Evangelical Church of India, hence ECI Matric. It has about 900+ students studying from Pre-KG to 12th standard. There is a church in the middle, the Academic block is to its left, the Office and the hostel are to its right. The standard size of the classrooms is about 30×30 ft (guessed never measured), which is kind of crampped when you consider there are 77 students, desks, bags, cupboard, and a divider wall in the middle to distinguish Section A and Section B.

My Class

My class was made up of 38 poor souls who did not know what they were doing, which included 1 adult trying to make sense of whatever was going on. The class had about 19 boys and 18 students from middle class backgrounds, so wide and varied that I actually don’t exactly remember what middle-class is now.

Timings

The school opened at about 8.30AM and the staff are supposed to sign the attendance register before 8.55AM. There is a morning prayer meeting at 8.55 in the church for all the christian teachers and at least one staff member of each grade are to be present, if they are non-christians. So I experienced more religion in my one year of fellowship than what I have seen in my 25 years of existence. The School gets over by 3.30PM and the tuition(s) are over by 4.30PM. Generally I left the school by 3.30PM.

I lived about 90 minutes away from the school, so my day generally started by around 7.15AM when I got out of the house and ended by 5.30PM when I got back to the house.

………………….. to be continued .,