Skip to main content
How Python implements “Data Encapsulation”?


Data privacy or “data encapsulation” is provided by Python by default. In Python every variable or method is scoped within its parent code block. Look at the below function-
  1. def newcurrencynote():
  2. newnote = 2000
  3. print("This is new" + newnote + "currency note")
  4. print(newnote)
  5. print(example())

In the above function newcurrencynote() the variable newnote inside the function has “ local” scope within that function, in other words it is private to that functions only and is not accessible outside that function . So, the first print function gives an error stating that you should initialize the variable first and then print it, but since the second function is trying to access the function itself so it will print the value of the variable.


If you found this post helpful and you have any suggestion to improve my blog then do post your comments below. Additionally you can also bug me on Quora. You can also find me on Twitter or Facebook. So, why wait go ahead and start exploring.


If you wanna get started in learning Python then why not get started with the python basics chapter. Check out this link to access the Python Basic Chapter for free.


If you want to download a copy of the chapter then purchase the chapter by clicking on the following link.

Comments

Popular posts from this blog

How To Install Tensorflow On Windows

Why I am writing this tutorial ?
Recently I have started learning machine learning specifically DeepLearning for one of my pet projects, and during this quest of mine I wanted to learn TensorFlow library which is developed by Google. Learning is one thing but first I needed to install the library, but there was this problem which I faced during the installation. I am using Anaconda as my package manager and trying to install the Tensorflow library on my work computer which is behind a proxy, installing directly from the anaconda cloud while behind a proxy always displayed a proxy error.

How did I resolve the issue? Well this is exactly what I am going to write down in the below tutorial. The Steps To Follow
Before we get all cosy with this short tutorial on Tensorflow installation, let me tell you that
this tutorial is on the assumption that you have already installed Anaconda on your machine and you know at least a few basic things or two about python.
If you want to learn basic pyt…
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 around the correct logic. Des…

For Loop in python 3 : How to become a Python Jedi - Beginners Python Programming Tutorial - Part 7

I am back again with another part in the beginner python programming tutorial series. We will continue with "Loops" but this time we are going to learn how to use for loop in python 3. 


Difference between For loop and While Loop
A "For Loop" and "While Loop" have a common connection that both are looping statement, but major difference is that unlike while loop, a for loop gets executed a specified number of times.



We can break down the For loop into the following components(Refer to the for loop flow chart below).
for keywordvariable namecall to the range functioncolon operatorclause or block of code Hovering over the flow-chart
The above flow-chart is..well horrible I know, but I make my own drawings because I can't afford an artist. So, bear with me. In the above flowchart is a very basicy, laymanish representation of a for loop. The decision box contains the For statement along-with it's soulmate i.e the Range function. As long as the variable I …