A dense, utilitarian overview that prioritizes rapid syntax delivery over deep conceptual understanding. It works as a quick refresher but lacks the pedagogical rigor expected of a university-level computer science course.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Tutorial 1
Added:All right, moving on. So, first let's look at variables and certain data types. The cool thing about Python is when you're declaring a variable, you don't really need to explicitly specify the data type of that variable.
Typically, in C++, you would do that.
However, here I just write uh x= 10 and automatically my compiler infers that x must be an integer. Similarly, I've declared another integer Y. I have declared a floating point, a decimal number Z. And then name is a string. Of course, you declare it within inverted commas. And then I have two boolean type variables which can either be true or they can be false.
All right. In order to access the data type of a given variable, this is what you do. Oh, just by the way on that note, this is how you print in Python, right? You can press shift and enter to run a cell. So if I want to display the data type of a certain variable, I will call the function type and enclose my variable within it. So when I do this for X, this is what it gives me. Class int.
um as long as it's the last part of your code cell, you don't really need to specify print either and it works just fine. So similarly, I can do it for all of these variables. So X is an integer, Z is a floating point, name is a string, and is raining is a boolean variable.
All right, with that, let's move on towards some arithmetic and logical operators.
Uh here you have a couple of arithmetic operators. A lot of these you would be familiar with already. Um addition, multiplication, division and modulus basically means remainder. So just on that note, let's copy these variables over here just so that their values are visible to you. All right. So I have um x + y, x * y, x / y and x modulus y means when you divide 10 by 3, the remainder essentially is going to be 1 and uh this means x to the power of um y.
All right, on that note, let's move on to a few uh logical operators.
uh you have a logical and and in Python you can either use the amperand sign or you can use the keyword and and they both will work exactly the same way. The same goes for the variable or or true return when either of the two things on uh in your condition are true. So true and true will true or true will return true. True or false or false or true will return true and only false or false will return false to you. But however when you use the and operator you need to ensure that both sides are true in order for it to return true. Similarly you have the not operator. So your not operator complement return. So if um is raining is true essentially this is going to return false to me.
Is raining is false in my case. All right. Are there any questions up until this point?
Okay. On that note, moving on. So next we have a few basic data structures in Python that you're going to be using very frequently.
Starting with lists. Lists are basically just arrays in Python. The good thing about lists in Python is that well your list does not really have to have elements from a single data type. You can have elements from multiple data types within a same within the same list. So I have um an integer, a floating point, a string, and I can just as well have a boolean variable.
In order to access one particular element of your list, you just specify the index. Indexing is always done starting from zero. So I I only have four elements. So indexes zero start and they'll go up until three. So my list zero will give me two one will give me 2.3.
And uh one interesting thing on that note when you write minus one so essentially this will give you the last element of your list.
If I write minus2, it will give me the second last element in my list.
You can also do slicing on a list. So just to quickly show you, if I write down one column three, so essentially it will give me indexes one and two of my list. Three is not included. So this is what I get.
All right. On that note, moving on towards dictionaries.
The dictionary data structure is particularly important to us when we're working with pandas because when we look at pandas data structures, so they are based off of simple dictionaries essentially. All right. A dictionary contains key value pairs in the form of a list you may say.
So um in an array essentially if I have array numbers key so this is what I have against the zerooth index I have the element one against the first index I have the element two against the second index I have three and against the third index I have four as opposed to that in a dictionary um your indexes are your keys keys. So right now my first key is name against name I have Alex. My second key is major and against major I have econ. And my third key is age against age I have stored 26.
So like uh you are trying to access a certain element on an index in an array you just use square brackets to refer to the particular index. Similarly, in a dictionary, you use square back brackets to refer to a particular key in order to obtain the value against that key.
If you want to um add a certain element to a list, this is how you would do so.
Numbers do.append. Suppose I add 10. And now if I print numbers, this is what it looks like.
If you want to add a certain element to a dictionary, this is how you would do so. Student and suppose I want to add gender is equal to male. That is how that would work.
All right. This is my dictionary. Now further you have sets and you have tpples.
Sorry, but those are not important for us at the moment. Are there any questions up until this point?
All right, we're good to move on then.
So, next up we have control flow. We have if and else statements. We have conditions. And then we have loops.
For those of you who have done programming in any other language prior to Python, you would be familiar with how conditional statements work.
These determine the flow of your um code. Either you go into um one branch of your code or you go into another and then you can have multiple conditions available. Your conditions may be aggregated as well.
So suppose I have declared a variable called marks and um now I want to be able to print the students grade based off of the marks that they have obtained.
So um this is how I would do so if marks is greater than or equal to 90 and then you have to have a colon and indentation really matters in Python otherwise your code will crash. So I want to display a grade of A. Otherwise, else if which for in short we write L if in Python marks are greater than or equal to 80 and marks are less than 90 then you would print B. Else anything below 80 and I will print C.
So that is how that would work. I can try changing marks over here and essentially grade accordingly update.
If you want to input a certain number into marks, this is how you would do it.
Marks equals input and that is how I would input something into it. However, by default, the type of marks would now be a string because whenever you take the user's input to string, if I want to type cast it and convert it into an integer, this is how I would do so.
And now marks is an integer.
This is how you add a comment in Python.
And now I'm using the marks.
Are there any questions up until this point?
All right, I suppose we can move on then. Next, we have loops. Loops allow you to execute a certain section of code a certain number of times up until a given condition is met. We have three kinds of loops. In C++, you have for loops, while loops, and dowhile loops.
In Python, we do not have dowhile loops.
You only have for loops and you have while loops. However, there's a lot that you can do with for loops for that matter.
So, let's see.
This is the syntax that you're going to be following. I believe in C++ you would write it down like this. Int i equals z that is initialization of your variable just iterate over your uh loop and then you write the condition that will break your loop. Suppose i is less than six and then you specify an incrementer.
So basically a piece of code that runs after every execution.
In Python on the other hand we write down for I in range is parameter pass that is the starting index then you specify the ending index and then you specify the jump. So I want to start from five, end at 20 and increment I by two after every single iteration. So this is kind of the same thing as writing down.
And let's see this is the output that I get essentially if I do not write down or do I do not specify the jump. So by default it's always going to be just one.
By the way, this is I is less than. So essentially 20 itself execute. At the same time, if I don't specify the starting index, the by default, it will start from zero.
Another cool way of um iterating over an array in Python is doing this. Oh, just on that note first let's look at this one. So I have an array which consists of five colors red, yellow, green, blue and orange. So for I in range L en of array.
So just by the way ln gives you the length of the array. So for instance is length three for this one I would get five.
So for i in range le n a r essentially is the same as writing this down and then I want to print the value of the array at each given index.
And this is how that would work.
As opposed to this, I could also directly iterate over my array by writing down for x in a ar r. So go over each element of your array and it works exactly the same.
On that note, let's look at while loops.
The good thing about for loops is key you can always specify your incrementer within the loop. For a while loop, you would have to separately specify them.
uh because within the loop statement you can only have the condition. So count equals zero while the count is under five you print count and then you have to manually increment count as well. If I remove this particular statement so essentially I have myself an infinite loop which will not terminate.
Are there any questions up until this point?
All right. So let's move on to words functions.
Functions are different from loops in the sense when you have a loop you are executing a certain piece of code up until a specific condition is met. When you have declared a function you have a reusable piece of code that you can call within the rest of your script whenever, wherever, and with whichever values you want. All right. So for instance, I have a function that prints suppose this isn't a format string any longer. Let's keep it simple or rather let's do it like that.
So suppose this is what my function does.
All right, you use the keyword define def for short. Then you specify the name of the function and then you specify any parameters that you want to pass to your functions.
So for instance, I have a function that takes no parameters and it just prints hello. So whenever I call this function, this is what would happen. Oh, you have to specify parenthesis. So function I can call it in another cell as well.
Now as opposed to this suppose I do pass the name and this is how that would work. Then suppose K I have declared a variable my name and now I want to pass my name to the function.
Oh I misspelled.
All right. So this is how that would work. And essentially you don't have to specify a variable over here. I can just directly pass a value as well and it will work just as well. And then I can reuse the same piece of code with other values as well.
Now this is a particular function that just does something. It doesn't return something to me. So I can modify it to return this string to me. Hello plus name. But then I would have to receive it somewhere as well. So suppose I receive it in the variable x. Now if I print x to x your string store of course I left no spaces in between. So this is what I get. Um and just like that I can call it again. Store the value in a different variable. And let's see what happens when I print both of them.
Ideally, I should have just left some gap in here.
Are there any questions up until this point?
Let's try and understand why this reusability is important to us.
Suppose I have an addition function and um it takes an array. Suppose I have an add function or add function essentially elements return.
So this is what I will do. Sum equals zero then for number in array sum plus equals number and then I can just return the sum.
So now suppose I have an array of numbers and uh I want to compute the total. So I will receive this in a variable. I will call the function on my array and then I can just print the total.
This is how that works and then I can reuse it for any given array.
Just by the way, I can call it on a string as well. A B C D E F G.
Apparently, I cannot uh because sum has been initialized to zero.
If I had initialized sum to an empty string, it would work just fine.
All right. Are there any questions up until this point?
Okay, now to quickly show you guys what a format string is because I got rid of it immediately. Bel. So a format string is a particular string. Typically we use these for printing where you have a certain variable and you want to include the value of that variable along with some other text. So you just declare it or you add it write it as a normal string and you just add F. F stands for format whatever variables you want to include curly brackets in between. So this is what that does.
If I were to remove these brackets, this is what I would get. Are there any questions up until this point?
Sadly, I left the solution right over here.
But this is what I need you to do.
Uh we are going to write down a function get area and this function a pass radius and we want this function to calculate the area of a circle with this given radius. We can use the value of pi as 3.14159.
So I will pause over here and I will give you guys a few seconds and I would encourage you all to try and figure out the solution to this the missing lines of code. Let's take a few seconds here.
If anyone would like to volunteer a solution after this I would be happy to hear from you. Otherwise I'll just add the solution and we'll move on. So let's give it 20 seconds.
All right. Would anyone like to volunteer a solution?
Okay. So, I'm just going to add this. um this is just a function call that I'm doing for a particular circle. So let's suppose I declare pi and then I compute the area which would be equal to pi ultiplied by radius multiplied by radius again and then I can just return this area.
So essentially it works perfectly fine.
Alternatively I could have just directly done this as well and it would have worked just fine.
And so I have myself a oneline function.
All right. Next, we are going to try and write down a piece of code that checks whether a given number is even or odd.
You're going to have a condition over here. So, uh let's try and take a few seconds to think about this. We don't have to declare a function for this.
Suppose number it is equal to 9. So I will give you guys 15 to 20 seconds to process This All right. Would someone like to give me a solution for this?
So guys, essentially when you're checking whether a number is even or not, you uh divide it by two and you see if it divides by two or not. For this purpose we have um a variable modulus which I showed you guys.
So if I take the modulus of number with two and it returns one to me to remainder one and the number is odd. If it returns zero then the number is even which means it divides by two. So this is what I will do.
number modulus 2 double equals for checking for comparison. If number modulus 2 equals 1 then I will print that it is odd.
Else the number is even.
So that is how we will do that. Let's quickly test it for an even number as well and it works perfectly fine.
Okay. So next we have another question.
You are required to count the lowerase vowels in a given string and this is the string that I have given to you as a sample. You would need to use a for loop to do this. So let's pause for a few seconds over here and I will give you guys the chance to figure this out.
All right. Uh, with that, let's move on.
And, um, I'm going to go ahead and add the solution for this. So for xn I can directly iterate over every single element within my string just by doing this. To show you guys how we do that, this is how I'm accessing each character at a time.
So if x is oh of course I have to maintain a count as well. So if x is equal to a or x is = e or x = i or x = o or x = u count + = 1. Then at the end let's print the count.
All right. Are there any questions at this point?
Okay, let's move on.
The exact same solution. Alternatively, um you could just do this as well. my str i for i in range l e n my str and that will work exactly the same way.
Let's look at the next exercise. I will give you guys a few seconds to think of how we're going to solve this as well before we move on. You are required to iterate over this list in order to find the maximum Remember?
All right, with that I'm going to go ahead and solve this.
So initially I can suppose that the maximum is at the first index of my list which is essentially the zerooth index.
Then I will iterate over my list and if x is greater than max then then max will be equal to x. At the end we can just print the maximum and that is how that works. After this, I would want you guys to try and find the second maximum in the list on your own. On that note, um I think we're going to move on to the last exercise before we go ahead and look at numpai.
So, I have two interesting exercises.
Just by the way, these are two popular interview questions as well. So let's suppose I have two variables and I want to swap the values of those two variables. You can either do this using a third variable or you can do it without using a third variable.
Um hold on just a second. Are these exercises on the kegel notebook?
Uh, Shebas, let me look into this at the end of the session, then reach out to me if it's still not updated.
There might be a small issue with the link. Hopefully not though. Okay.
Anyway, let's first try and do this using a third variable. I will give you guys about 10 seconds. Surely everyone should be familiar with this problem.
All right. Would someone like to volunteer a solution?
Really, guys? No one. Okay, I'm going to go ahead declare a third variable. Store the value of A in C. All right. Sorry.
Store the value of Yeah, I was right. So A value Copy.
Next A can be equal to B and B can be equal to C. So now if I print A and B.
So essentially A and B key value swap. A is six and B is sorry A is 8 and B is six. Now, but the real uh tricky thing is how do you do this without using a third variable and again I will give you guys about 15 to 20 seconds and then if anyone is able to figure this out share solution otherwise I'll just add it and we'll move on.
All right. Has anyone been able to figure this out?
So, a equ= a + b stored here 14.
B= A minus B. And what do I have in B now?
6.
A= A minus B. And what do I have in A now? eight.
So just something interesting to show you guys. This is a fairly popular level zero interview question.
All right. With that, let's move on to words uh numpy.
All right. So essentially numpy is full for numerical python. A lot of you may a lot of you may be familiar with this library already. Excuse me.
All right, moving on. So, numpy is a very powerful library in Python that you use for numerical computing tasks when you have very large array or very large multiple higher dimensional matrices.
For instance, in for instance in image processing or when processing large scale data sets, you use numpy in order to uh do multiple operations very efficiently. Numpy is built on C. It is able to support multi-dimensional arrays.
All right, this is how you use numpy. So first up is go import numpy as np. Now whenever you want to use a numpy function you just call np. All right. So first to show you how numpy arrays are essentially different from simple arrays. This is how you declare a simple array and then if you want to convert it to a numpy array to surf npar function call and then you pass your array to it.
When I print my array, it will simply display all its elements. When I want to print the data type of my array, so this is what it gives me. Numpy ND array where ND stands for N dimensional.
Similarly, if I declare a 2D array, this is what that would look like. Now I have a matrix of size uh 2 by3 in front of me.
The cool thing is if I were to do simple operations, for instance, if I have two arrays and now I want to compute an element wise sum. So this is how I would do so. I have a new array called result and then I'm going to iterate over the length of any of these two because they both essentially have the same um length. And then I add every single element at this point maybe I and then I just add it to my result. And this is what I get. The good thing about numpy is you can do this exact same operation just for my and for our information to test it out. When you do that in numpy, if these are your two numpy arrays and you just do result equals a r1 + 2 to automatically element wise addition, you don't need to have a uh separate loop in order to simply do that.
Similarly, you can do element wise multiplication, division, scalar multiplication, modulus, power, and quite literally anything that you want to do with multiple arrays at once. They could also be multi-dimensional arrays. So, it's a pretty strong library.
Now, to look at a few properties of numpy arrays. By the way, you're going to be um dealing with these every now and again in your graded homeworks.
So, I have declared a two-dimensional array. If I want to uh print the shape of my array, this is how I would do so.
Dot shape call. And this tells me that I have two rows and three columns in each row. If I want to just access the number of dimensions, which by the way means the number of rows, this is how I do so.
Array n dimensions ndim.
And this is what I get.
Are there any questions about numpy up until this point?
So I'm going to show you guys a few useful functions that the library has to offer. If you want to create an array of zeros, you directly call np.zeros and array shape specify.
This will give me a matrix of size 3 + 3 consisting of zeros only. This will give me a matrix of shape 2 + 4 consisting of ones only. So let's try and display these. And this is what that looks like.
Similarly, I can generate numbers in a certain range as well. So, uh for that you have the function arrange np.t arrange. You specify the starting point just like you would in a for loop. You specify the stopping point and then you specify the incrementor. So I want to generate a list of numbers between 1 and 20 uh with a step count of two and this is what I get.
Essentially I can change this as well. I could uh do it from 10 till two with a step count of minus2 and that is what I get.
You can also generate random numbers. So I'm just going to remove this line for now and tell you guys how you do it.
So np.trandom dotrandom. Yes, you have to write dotrandom twice. And about you just specify the shape of the array that you want to generate. So I want a 2 +2 matrix consisting of random numbers between 0 and 1. Essentially this is how I will do it.
All right. So now I have a two-dimensional numpy array. On the other hand, if I want an array of just integers within a specific range. So np.trandom dot rand. So between 2 and 10, it gives me a matrix of shape 2 + 2 with random integers only. And this is what that looks like. So every single time I get a new array and range just by the way.
Oh, apparently not. My bad. In the simple random function, you cannot do this. You can do it in rand int only. I can change the shape of the resultant array that I want to display.
And with that um that will be all for numpy. Are there any questions up until this point?
So there are a handful of exercises that we're quickly going to go over. First, I want you guys to try and create a onedimensional numpy array with numbers ranging from 1 till 10. I will give you guys a few seconds before I just show you the solution.
Um, so for those of you who don't remember, nparange a function call going and then see what goes in there.
So this is how you would do so.
NP.arrange arrange 1 till 10 with an incrementer of just one. And I believe even if you don't specify an incrementer, it still works that way. If you don't specify a starting point, it starts at zero by default.
Let's look at the the next one. Now try and multiply each element by five without iterating over the entire array.
So you will directly multiply the entire array by five. And this is how that works.
Next, let's try and find the sum of all elements in the array. I actually haven't shown you guys this function. So I'm just going to go ahead and tell you.
Similarly, if you want to find the maximum element, this is how you would do so. And that works just as well. The same way you can do dot min and you can do dot mean as well. So just to try it out, arr.
So that works pretty okay as well. Next, let's try and create a 3 + 3 array of random numbers between 0 and 1 using np.trandom.random.
So, in order to generate an array between 0 and one, you don't have to specify anything except for the shape of the array.
Um I have already shown you how to find the maximum number as well as the mean up directly mean and np mean.
On that note I think that that will be all from my side. Are there any questions before we wrap up this session?
All right. I would highly encourage you all to set up Kegel before the next upcoming tutorial. All right, that will be all from my side. Thank you guys.
Allah
Related Videos
LBF101 Creating an XML Changelog
liquibase7511
3K views•2026-06-15
Alta Labs Cloud Dashboard Real time Network & Xnet Insights!
ShinyTechThings
158 views•2026-06-17
Wait... Group Policy Not Applying? Check This First!
keeplearning_iT
144 views•2026-06-15
Leetcode Weekly Contest 506 | Life's boring these days
Pudeesht
2K views•2026-06-14
microJAM: MAKING A MICRO GAME FOR A GAME JAM IN CLOJURESCRIPT AND TOTALLY NOT C
janetacarr
156 views•2026-06-18
Partitioning vs Bucketing vs Clustering: How to Make Queries 100x Faster
thedataandaiguy
194 views•2026-06-16
Design Claude Code Like a Senior Engineer
hayk.simonyan
344 views•2026-06-19
Linus Torvalds: AI Won’t Replace Understanding Code
SavvyNik
140 views•2026-06-19











