Introduction to Programming with Python
Out of all the subjects I have learned till now the only class I felt the most powerful enough after only one-hour teaching was the class of programming. This is the only class where I felt like I had the power to make anything or build anything which can be used by the masses. Programming can be the bridge between one’s imagination and reality.
It was the second week of August and our freshers had just stepped in their undergraduate college. We could see their eyes beaming in hope and excitement to learn and make new things. Well, why wouldn’t they be so excited to learn something new, after all, they were now a part of an engineering college. So the team decided to hold the “Introduction to Programming” workshop to get the freshers started with programming and introduce them to a new world to explore.
Why did we choose the Python programming language for this workshop?
There were three main reasons. First, Python has a very easy syntax. You won’t waste a lot of time memorizing the arcane syntax that other programming languages will present you. Things like declaring variables, printing operations, and running loops have a very easy and intuitive code. Second, Python has excellent code readability. Its code is so “English-like” that even a non-programmer might be able to understand what the code’s purpose is. Also, it uses indentation to define separate blocks of code. This further enhances its readability and makes the code look cleaner. Third, Python has tons of useful libraries like NumPy, Pandas, and Matplotlib. It makes things like computation of multidimensional arrays, creating manipulable objects from simple data and creating publication-quality plots and figures very easy without writing separate code for it. This is also the reason why Python has become very popular in the last few years because of its usefulness in AI and ML related fields. Hence, to get them started with Python would increase their interests in various complex fields of programming too. But Python’s disadvantage is that it is a very slow language compared to C/C++ and may not be used in applications where time is critical.
The Introduction to Programming with Python workshop was held over two days in the college’s computer labs. We had over 340 participants from all departments like Electronics and Communications Engineering, Mechanical Engineering and not just Computer and IT students. This response was so much better than what we had expected.
Participants were made to use the Python 3.x.x using its interpreter on the command prompt in the Ubuntu operating system. This was done so that they get used to the feel and environment of programming and realize how important it is to be exact because many of them just get used to the ease of writing code in a friendly editor. Of course, many of them had difficulties running their Python code or using Ubuntu during the workshop but we believe that it helped them gain experience.
We started with absolute basics as many of the attendees were new to programming. On the first day, we explained to them the difference between a compiled and interpreted language. Python being an interpreted language is also one of the many reasons people prefer using it.
We began with the concept of print statements and how it was used to output to the console. The participants used the print() statement in Python to print sentences, concatenate strings and perform basic calculations. While concatenating and printing various things people noticed that they were not able to concatenate a sentence and a number(unless the number was in quotes). And hence various basic data types like Integer (int, numerical value without a decimal point), Floating Point (float, fractional numbers), String (str, sentences)were introduced. The two new data types for those who did a bit of programming were Boolean and None. Boolean (bool) can hold only one of two possible values: True and False. The last type was None which is a special type indicating nulls.
Along the way, we also introduced the participants to the concept of variables. Many of those who had experience with C++/Java remarked how easy it was to declare a variable in Python(without specifying its data type) and change its data type fluidly. Many were curious to know the reason for the same, Python doesn’t actually “hold” any data but is merely pointers to data objects. We then moved on to the basic assignment and arithmetic operations in programming. Many of them were new to the modulo (%), the floor division (//), and the power of (**) operators. We then gave them a simple problem to solve for some practice using the things they learned.
Comparison operators were then taught along with conditional statements, its syntax, working and how the or, and operators were used in it. Now that the participants were familiar with the basic syntax of Python and programming logic, they understood this part easily.
Next, we moved on to looping statements. While being taught for loop, they were also introduced to the range() function in Python along with its start, stop and step parameters. A small question that included calculating the GCD of two numbers was done. With this, we concluded Day1.
Day 2 began with revising and solving any doubts from the previous day. Then we commenced the session with built-in data structures of Python (lists and dictionaries). The list is an ordered collection of data in Python. Its syntax,indexing, working and basic operations like len(), append(), sort(), and list concatenation were taught. They were also introduced to the map() function and list slicing. Next, we moved on to dictionaries in Python and its key-value structure was explained. Since dictionaries make use of Hashmaps searching in dictionaries is faster than lists. Different dictionary functions like .keys(), .values(), .get(key), etc. were taught.
When functions were taught, the participants immediately remarked on its usefulness and how it makes code reusable. Functions are majorly useful for their recursion property. Many of them were a bit confused about this concept but they understood it with examples such as calculating the factorial of a number, Fibonacci numbers, Euclidean Method of calculating GCD which also gave them a much better understanding of the importance of recursion.
Last but not least, the participants had to give a small MCQ-test to be eligible for a certificate for this workshop. It was overall an excellent result with almost all scoring above merit.
We later gave them a short introduction on Competetive Programming(CP) and took them on a tour on the Codechef website. We chose this CP website since CodeCell is a campus-chapter of Codechef. A very basic problem was solved by all our contestants on the site and everyone managed to get their first green tick.
We received very positive reviews from all our participants. They liked the choice of language, the course content and the hands-on approach of our workshop. They were very happy to have a head-start for programming. They developed a decent hold on programming during our workshop and looked forward to attending our future workshops.
“The guide answered each and every query and helped us in every way possible :)’’ — participant
“I really liked the way in which the things were explained in a brief but fun manner” — participant
We were overwhelmed by the response and the feedback and couldn’t have been more thankful to all the freshers who showed great enthusiasm in our first workshop itself. We hope to conduct more workshops on advanced topics and see you again.
One of the best resources to learn python is from the book automatetheboringstuff.com