Found 33579 Articles for Programming

Program to Print K using Alphabets

Niharika Aitam
Updated on 06-Nov-2023 11:55:14

311 Views

Python is used to print different patterns easily within less time as per the user requirement. In the same way, we can print the letter K using the alphabets available in the English language. Example In this example we will create the letter K by using the K alphabet. The below is the code. string="" j = 7 i = 0 for Row in range(0, 10): for Col in range(0, 10): if (Col == 1 or ((Row == Col ... Read More

Program to print window pattern

Niharika Aitam
Updated on 06-Nov-2023 12:10:20

244 Views

Python is one of the most popular and efficient programming language which helps the developers to write and execute the code very easily and faster. It provides several methods, packages, modules and libraries to develop the code within no time and with less complexity. A window can be a square or a rectangle or a triangle with having a plus sign or without a plus sign, in the middle. In order to print the window pattern using the python language let’s see an example and understand. Example In this example, we will create a window in the rectangle without ... Read More

Print objects of a class in Python

Niharika Aitam
Updated on 06-Nov-2023 12:22:16

4K+ Views

An object is the part of the Object Oriented Language (OOPs), which is an instance of the class. The class is the blueprint or template that specifies the methods and properties of that given class. When we create an object of a class, it contains all the set of instance methods and variables that are related to that particular object Using __str__ method We have two methods namely, __str__ or __repr__ in python which automatically calls the string and used to print the object with the detail view about it. Following is the syntax for using the __str__ method. ... Read More

Django Form submission without Page Reload

Niharika Aitam
Updated on 06-Nov-2023 12:27:03

1K+ Views

In Django, we can submit the form without reloading the page using the Jquery and Ajax (Asynchronous JavaScript and XML) requests. Let’s see an example to work with the Ajax to submit the Django form without reloading the page. Create a new Django project First create a new project in Django with the name Reload_project and also create a new app in the project directory with the name Reloadapp by executing the below commands in the command prompt. django-admin startproject Reload_project cd Reload_project django-admin startapp Reloadapp Now in INCLUDED_APPS in settings.py file of the Reload_project directory, add the ... Read More

Django form field custom widgets

Niharika Aitam
Updated on 06-Nov-2023 12:34:32

190 Views

A widget is the representation of the Html input element using Django. The widget is used to handle the rendering of the HTML page and data extracting from the POST/GET dictionary. Every time whenever we specify the field on a form, Django uses the default widget to display the data in an appropriate manner. Django is the one of the best Framework used by most of the users, to perform the web development. It provides many advanced features, functions and packages to design the best web pages and connect with the servers using the python programming language. Now let’s ... Read More

Django CRUD (Create, Retrieve, Update, Delete) Function Based Views

Niharika Aitam
Updated on 06-Nov-2023 13:02:39

883 Views

CRUD is abbreviated as Create, Retrieve, Update and Delete Functions. In Django, we can perform all these CRUD operations on the data we created into the database. Now let’s create the views.py function based on the operation that we want to perform. Create Operation with Django Create is used to create or add new data entries to the database table. In the following snippet, we begin by importing both the model form and the corresponding model. Next, we proceed to check whether the request is a POST request. If it is a POST request, we create a new form ... Read More

XOR Linked List – A Memory Efficient Doubly Linked List

Divya Sahni
Updated on 03-Nov-2023 15:28:07

2K+ Views

Linked List The linked list is a linear data structure containing elements called nodes. Each node consists of two main components: data (payload of that node) and a pointer to the next node in the list. They are simple and efficient to use providing easy allocation and deallocation of memory. Doubly Linked List Doubly linked list is a special type of linked list which again consists of a basic element called nodes. Each node consists of three main components: data (payload of that node), a pointer to the previous node of the sequence and a pointer to the next ... Read More

Sort numbers stored on different machines

Divya Sahni
Updated on 03-Nov-2023 15:12:14

850 Views

In today’s world with a large amount of data and interconnected systems, a vast amount of data is created and stored across various machines. One challenging challenge is to sort this data stored across multiple devices. Sorting being a fundamental operation in computations is used for optimal retrieval, search and analysis of data. But with distributed systems and various interconnected machines, this task of sorting becomes difficult and important. Problem Statement Given an array containing N linked lists that depict N different machines. Each of these linked lists contains some variable number of numbers in sorted order. The task is ... Read More

Segment Tree | Sum of a given range

Divya Sahni
Updated on 03-Nov-2023 15:10:40

855 Views

Segment Tree A segment tree is a tree data structure used for storing intervals and segments. It is a static structure, i.e. it cannot be modified once it is built. Segment trees are used to handle range queries on an array or a similar linear data structure. In a segment tree, we divide an input array into segments and precompute the values for these segments. Each node in a segment tree depicts an interval or segment of the array. The root node represents the entire array and each child node represents the segments formed by dividing the parent node. This division leads ... Read More

Segment Tree | Range Minimum Query

Divya Sahni
Updated on 03-Nov-2023 15:06:10

1K+ Views

Segment Tree − A segment tree is a tree data structure used for storing intervals and segments. It is a static structure, i.e. it cannot be modified once it is built. Segment trees are used to handle range queries on an array or a similar linear data structure. In a segment tree, we divide an input array into segments and precompute the values for these segments. Each node in a segment tree depicts an interval or segment of the array. The root node represents the entire array and each child node represents the segments formed by dividing the parent node. This ... Read More

Advertisements