Skip to main content

Posts

Multi-assignment in Python

Multi-Assignment in Python Hello guyz welcome back to thecodingproject after a loong loong  time 😌. This past couple of days I was very busy in my other projects and some personal stuff so could not get much time to post anything here but now I am back and I have another topic in #python to deal with. Today we are going to explore what is “Multi-Assignment”. It’s better to get straight into an example. Let’s consider three variables k.l & m and a list [1,2,3]. Now when you do the following in the python prompt - k,l,m = [1,2,3] Print(k) print(l) print(m) Output is : 1 2 3 Here each variable (k,l,m) are assigned to each element in the list in that order. That’s why when you type in k you get 1, l gets you 2 and m gets you 3. Instead when you do the following - k,l,m = 1 You will get the following error- Traceback (most recent call last):  File "<input>", line 1, in <module> TypeError: 'int' object is not iterable Th...
Hey friends welcome back to Thecodingproject. You guys must have noticed that last week I didn’t post anything on my blog and that’s because I was having a vacation time with my friends so I couldn’t get time to get online. Even today I am not here to post any article or any tips/tricks here. I am here to say a 1000 THANK YOU😂 to you guys and that’s because you people are awesome. It’s because of your love and attention that my blog has now 1000+ views in such a short period of time. I started this blog during November last year with the aim of sharing my knowledge and experience in software programming with the internet community because it was from this community that I self-taught myself coding, so sharing what I have learned over my blog was my way of giving back something to the community. Here is a snapshot of my blogger stats page These 1000+ views are not just page views for me, infact these 1000 views are the 1000’s of love that you all have given me and in thi...
Programmer’s skill set Hey guys welcome to another article of Thecodingproject. Today I will share an answer to another interesting question for you budding programmers out there. When I first started learning to code this same question came to mind time and again and the question was what skills sets I should posses as a programmer ? What tool set should I start collecting in my coding toolbox ? A programming language is just an ends to meet the automation/programming goal of a software engineer. So, I would like to touch base on the skills required by an automation engineer irrespective of the language skill set since it would be applicable to every type of programming language be it JAVA, R , Python etc. So, let's see what skills we need to have as a automation engineer- Logical skills- This is a rather obvious skill that every programmer should have because a even writing the first line of code requires logical thinking so that you can frame your code ...
What next after learning Python ? Learning  a new programming language is like getting a new powerful Motorcycle. You have that shiny new machine which is a work of art and is powerful like a beast. What you do with it? You ride it for a couple of days at neck break speed tackle on a few twisties seek attention of a few people my twisting the hell out of the throttle and then after a few days you just keep it in your garage where it sits idle for a couple of months or years till the time when you again get in the mood to take your old love for a whirl. Well, I don’t do that with my motorcycle or my programming skills and I would suggest that you don’t do it either. Programming is a lot like acquiring a new motorcycle skill, the more you use it responsibly the more mastery you get in it. Many time I see people learning a programing language and then just keep it in their mind vault for months or years without using it sometimes it’s out of being clueless as to where to imp...
Hey Friends I need your help Hey friends, here at TheCodingProject I constantly try to post topics and articles which are based on questions/topics requested by you on Quora , Twitter & Facebook . It's my constant endeavor to bring to you the best answers to your questions which will satisfy the curious geek in you But I don't think that that it's sufficient, I want to share more with you and for this I am planning to share with you my experiences and Knowledge that I have gained during the years of my tenure in the software industry so that I can also help you achieve your goals and progress in your professional life. I am planning to share this information with you in the form of a book but I really need your help on the project that you want me to work so that I can give you what you want. So, Please fill in the below short survey which will point me in the direction of your thought. Loading...
What is the scope in python? Hey everyone TheCodingProject is back with the answer to another question from the world of Python and this time it’s about the “scope” in python code. In Python the scope is indeed decided by the number of indents. It must be 4 spaces. In Python every object always has a local scope and the scope is always decided by the indent of that particular block within which the object is defined. Let's consider an example def foo (): var = 'abc' return var In the above example, the scope of the variable var is limited to the function foo and how is the scope of the variable var is defined? It's defined by the indent that it maintains I.e. by making the indentation such that it comes under the function definition of foo, which tells the Python interpreter that the variable var is within the local scope of function foo. Now if you do the following - def foo ():    var = 'abc' return var v...
Testing Python Code Testing your code is very important to know if your code is having the expected behavior. No one likes a software program which would give a weird result or a program which would break in the middle of a critical task and throw of ugly error codes. For this and many more reasons it’s very important to test you code before making it public, testing is not a “best practice” rather it’s a necessity to deliver clean and delicious code which will obey all the commands that the user provides. There are many different python modules like unittest that help you to test units of your code and then there are some tools like py.test that helps you achieve the same goal, but I want to point out a simple & fast way to quickly test your piece of code without importing any separate module other than the one that is included in your project or which you have created for testing your code. Testing code in isolation In every type of code you must first design your c...