Programming Articles - Page 601 of 3363

Numpy Array advantage over a Nested List

AmitDiwan
Updated on 15-Sep-2022 12:11:12

2K+ Views

In this article, we will learn about the advantages of a Numpy array with a Nested List in Python. The Numpy array definitely has advantages over a Nested. Let’s see the reasons − The array in Numpy executes faster than a Nested List. A Nested List consumes more memory than a Nested List. Numpy Array NumPy is an N-dimensional array type called ndarray. It describes the collection of items of the same type. Items in the collection can be accessed using a zero-based index. Every item in an ndarray takes the same size of block in the memory. ... Read More

Explain how Python is an interpreted language

AmitDiwan
Updated on 15-Sep-2022 11:59:15

5K+ Views

Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. Python is processed at runtime by the interpreter. You do not need to compile your program before executing it. This is similar to PERL and PHP. Steps of Execution Step1 − A Python source code is written by the coder. File extension: .py Step 2 − The Python source code a coder writes is compiled into python bytecode. In this process, a file with the extension .pyc gets created. Step 3 − The Virtual Machine executes the .pyc extension file. Consider the Virtual Machine is the runtime engine of ... Read More

How to use the slicing operator in Python?

AmitDiwan
Updated on 15-Sep-2022 11:54:39

3K+ Views

The slice operator is used to slice a string. The slice() function can also be use for the same purpose. We will work around the slice operator with some examples What is Slicing? Slicing in Python gets a sub-string from a string. The slicing range is set as parameters i.e. start, stop and step Syntax Let us see the syntax # slicing from index start to index stop-1 arr[start:stop] # slicing from index start to the end arr[start:] # slicing from the beginning to index stop - 1 arr[:stop] # slicing from the index start to index ... Read More

What is PEP8?

Vikram Chiluka
Updated on 15-Sep-2022 09:33:17

2K+ Views

In this article, we will explain PEP8 and its uses in python. Also, we will see its advantages while coding. What is PEP8? PEP is an abbreviation for Python Enterprise Proposal. Writing code with good logic is a crucial aspect of programming, but many other important elements can affect the quality of the code. The developer's coding style makes the code more reliable, and every developer should remember that Python rigidly follows the string's order and format. A good coding style makes the code more readable. The code is simplified for the end user PEP 8 is a document that ... Read More

What is a default value in Python?

Vikram Chiluka
Updated on 15-Sep-2022 09:31:51

16K+ Views

The Python language has a different way of representing syntax and default values for function arguments. Default values indicate that if no argument value is given during the function call, the function argument will take that value. The default value is assigned by using the assignment (=) operator of the form keywordname=value. Example # creating a function by giving default values def tutorialspoint(website, author ='XYZ', language ='Python'): print(website, "website article is written by the author", author, "of language", language) Function call without keyword arguments Example # creating a function by giving default values def tutorialspoint(website, author ... Read More

Name mutable and immutable objects in Python

Vikram Chiluka
Updated on 15-Sep-2022 09:25:17

819 Views

In this article, we will explain to you the mutable and immutable objects in python. Python considers everything to be an object. A unique id is assigned to it when we instantiate an object. We cannot modify the type of object, but we may change its value. For example, if we set variable a to be a list, we can't change it to a tuple/dictionary, but we may modify the entries in that list. In Python, there are two kinds of objects. On the one hand, there are objects that can change their internal state (the data/content inside ... Read More

How do map, reduce and filter functions work in Python?

Vikram Chiluka
Updated on 15-Sep-2022 09:21:53

13K+ Views

In this article, we will show you the Python's map(), filter(), and reduce() functions add a touch of functional programming to the language. All three of these are convenience functions that can be replaced with List Comprehensions or loops but offer a more elegant and concise solution to some problems. map(), filter(), and reduce() all work in the same way. These functions accept a function and a sequence of elements and return the result of applying the received function to each element in the sequence. map() function Like reduce(), the map() function allows you to iterate over each item in ... Read More

Difference between indexing and slicing in Python

Vikram Chiluka
Updated on 15-Sep-2022 09:05:41

14K+ Views

In this article, we will explain to you the differences between indexing and slicing in python. Indexing and slicing are applicable only to sequence data types. The order in which elements are inserted is preserved in sequence type, allowing us to access its elements via indexing and slicing. To summarise, Python's sequence types are list, tuple, string, range, byte, and byte arrays. And indexing and slicing are applicable to all of these types. Indexing The term "indexing" refers to refers to an element of an iterable based on its position inside the iterable. The indexing begins from 0. The ... Read More

Difference between for loop and while loop in Python

Vikram Chiluka
Updated on 26-Aug-2023 03:25:00

53K+ Views

In this post, we will understand the difference between the 'for' and the 'while' loop. For Loop A for loop is a control flow statement that executes code for a predefined number of iterations. The keyword used in this control flow statement is "for". When the number of iterations is already known, the for loop is used. The for loop is divided into two parts − Header − This part specifies the iteration of the loop. In the header part, the loop variable is also declared, which tells the body which iteration is being executed. Body − The body part ... Read More

How to add groups in Django using authentication system?

Gayatri Jandhyala
Updated on 05-Sep-2022 11:06:24

3K+ Views

Django is equipped with built-in permissions system that assigns permissions to specific users or groups of users. Permissions used by the Django-admin site are as follows, Users with the "view" or "update" permission for that type of object have access to view objects. Only users with the "add" permission for that type of item have access to view the "add" form and add an object. Users having the "change" permission for that type of item have access to the change list, the "change" form, and the ability to change an object. Only users having the "delete" permission for that ... Read More

Advertisements