What do you mean by the csrf_token?
The csrf_token is used for protection against Cross-Site Request Forgeries. This kind of attack takes place when a malicious website consists of a link, some JavaScript, or a form whose aim is to perform some …
Program to count the number of capital letters in a file?
Python program to count the number of capital letters in a file. with open(FILE_NAME) as my_file: count = 0 text = my_file.read() for character in text: if character.isupper(): count += 1 print(count)
What is PEP 8?
PEP stands for Python Enhancement Proposal. A PEP is an official design document that describes new features proposed for Python and documents aspects of Python, like design and style, for the community. PEP 8 exists to …
What are unit tests in Python?
Python | What are unit tests Unit test is a testing technique to check a single component of code and ensures that it performs as expected. Unit tests are an important part of regression testing to ensure that …
What is main function in python? How do you invoke it?
Python | Main Function In the world of programming languages, the main is considered as an entry point of execution for a program. But in python, it is known that the interpreter serially interprets the file …
Set path and environment variables in Windows 10
Windows | Set path and environment variables in Windows 10 Press the + to access the Power User Task Menu. Now, select the System option. In the About window, click the Advanced system settings link under Related settings from the right side. In the Advanced tab, click the button. In …
What architecture does Django use?
Django follows a Model-View -Template (MVT) architecture which is a variant of the MVC architecture. Model: Logical data structure behind the entire app and signified by a database. A model is used in Django to …
Differentiate between deep and shallow copies.
Python | Deep and Shallow copies Shallow copy does the task of creating new objects and storing references to original elements. This does not undergo recursion to create copies of nested objects. It just copies the …
How is memory managed in Python?
Python | Memory manage Python has a private heap space to hold all objects and data structures. Being programmers, we cannot access it; it is the interpreter that manages it. But with the core API, …
“in Python, Functions Are First-class Objects.” What Do You Infer from this?
It means that a function can be treated just like an object. You can assign them to variables and pass them as arguments to other functions. You can even return them from another function. You …
What is __init__ in python?
Python | __init__ constructor method __init__ is a constructor method in Python and is automatically called to allocate memory when a new object/instance is created. All classes have a __init__ method associated with them. class Student: …
What is a cookie in Django?
Django | Cookie A cookie is a small piece of information that is stored in the client's browser. It is used to store a user’s data in a file permanently (or for a specified time). Cookie …
Set up environment variables in Django
Django | Set up environment variables in Django 1. Install Django Environ In your terminal, inside the project directory, type: $ pip install django-environ 2. Import environ in settings.py import environ 3. Initialise environ …
What is an Interpreted language?
Interpreted language An Interpreted language executes its statements line by line. Languages such as Python, Javascript, R, PHP, and Ruby is a prime examples of Interpreted languages. Programs written in an interpreted language runs directly from …
What are negative indexes and why are they used?
Negative indexes mean that you count from the right instead of the left. So, list[-1] refers to the last element, list[-2] is the second-last, and so on.