irst of all, I’m not the one on that image above. I’m just a benevolent writer who is here to talk about one of the most confusing concepts in Python programming “Global, Local and Nonlocal variables”. I know after reading the title you will be like “Why should I even worry about this”. Well, the answer is sometimes not knowing these teeny tiny itsy bitsy would cost you a lot. So without further ado, let’s get started.
F
irst of all, I’m not the one on that image above. I’m just a benevolent writer who is here to talk about one of the most confusing concepts in Python programming “Global, Local and Nonlocal variables”. I know after reading the title you will be like “Why should I even worry about this”. Well, the answer is sometimes not knowing these teeny tiny itsy bitsy would cost you a lot. So without further ado, let’s get started.
In programming languages like C/C++, every time a variable is declared simultaneously a memory would be allocated this would allocation would completely depend on the variable type. Therefore, the programmers must specify the variable type while creating a variable. But luckily in Python, you don’t have to do that. Python doesn’t have a variable type declaration. Like pointers in C, variables in Python don’t store values legitimately; they work with references highlighting objects in memory.
The list of topics that would be covered in this article is given below:
**NameError**
A variable is more likely a _container _to store the values. Now the values to be stored depends on the programmer whether to use integer, float, string or etc.
A Variable is like a box in the computer’s memory where you can store a single value. — Al Sweigart
_Unlike in other programming languages, in Python, you need not declare any variables or initialize them. _Please read _[**_this](https://stackoverflow.com/a/11008311/11646278).**
The general syntax to create a variable in Python is as shown below:
**variable_name**
= **value**
The **variable_name**
in Python can be short as sweet as **a, b, x, y, ...**
or can be very informative such as **age, height, name, student_name, covid, ...**
Although it is recommended keeping a very descriptive variable name to improve the readability.
Python is an interpreted, high-level, powerful general-purpose programming language. You may ask, Python’s a snake right? and Why is this programming language named after it?
Guide to Python Programming Language
Today you're going to learn how to use Python programming in a way that can ultimately save a lot of space on your drive by removing all the duplicates. We gonna use Python OS remove( ) method to remove the duplicates on our drive. Well, that's simple you just call remove ( ) with a parameter of the name of the file you wanna remove done.
In this tutorial, you’re going to learn a variety of Python tricks that you can use to write your Python code in a more readable and efficient way like a pro.
Magic Methods are the special methods which gives us the ability to access built in syntactical features such as ‘<’, ‘>’, ‘==’, ‘+’ etc.. You must have worked with such methods without knowing them to be as magic methods. Magic methods can be identified with their names which start with __ and ends with __ like __init__, __call__, __str__ etc. These methods are also called Dunder Methods, because of their name starting and ending with Double Underscore (Dunder).