Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 2216 of 2650
3K+ Views
In this article, we will learn about how we can initialize matrix using two dimensional list in Python 3.x. Or earlier.Let’s see the intuitive way to initialize a matrix that only python language offers. Here we take advantage of List comprehension. we initialise the inner list and then extend to multiple rows using the list comprehension.Example# input the number of rows N = 3 # input the number of columns M = 3 # initializing the matrix res = [ [ i*j for i in range(N) ] for j in range(M) ] # printing the matrix on screen row ... Read More
843 Views
In this article, we will learn about increment and decrement operators in Python 3.x. Or earlier. In other languages we have pre and post increment and decrement (++ --) operators.In Python we don’t have any such operators . But we can implement these operators in the form as dicussed in example below.Examplex=786 x=x+1 print(x) x+=1 print(x) x=x-1 print(x) x-=1 print(x)Output787 788 787 786Other languages have for loops which uses increment and decrement operators. Python offers for loop which has a range function having default increment value “1” set. We can also specify our increment count as ... Read More
1K+ Views
In Statistical analysis study of data variability in a sample indicates how dispersed are the values in a given data sample. The two important ways we calculate the variability are Absolute Deviation and Mean Absolute Deviation.Absolute DeviationIn this method we first find the mean value of the given sample and then calculate the difference between each value and the mean value of the sample called as the absolute deviation value of each data sample. So for the values higher than mean the value the deviation value will be positive and for those lower than the mean value the deviation value ... Read More
1K+ Views
In this article, we will learn about the 4 inbuilt data structures in python namely Lists, Dictionaries, Tuples & Sets.ListsA list is an ordered sequence of elements. It is a non-scalar data structure and mutable in nature. A list can contain distinct data types in contrast to arrays storing elements belonging to the same data types.Lists can be accessed by the help of the index by enclosing index within square brackets.Now let’s see an illustration to understand list better.Examplelis=['tutorialspoint', 786, 34.56, 2+3j] # displaying element of list for i in lis: print(i) # adding an elements at end of ... Read More
143 Views
In this chapter we see what happens when we update the values in a tuple, which is actually immutable. We will be able to merge new values with old values but that throws an error. We can study the bytecode of the error and understand better how the rules for tuple work.First we define a tuple and then issue a command to update its last element as shown below.Example>>> tupl = (5, 7, 9, [1, 4]) >>> tupl[3] += [6, 8]OutputRunning the above code gives us the following result −Traceback (most recent call last): File "", line 1, in TypeError: ... Read More
201 Views
In this article, we will learn about the usage and implementation of id() function in Python 3.x. Or earlier. It is present in Python Standard Library and is automatically imported before executing the code.Syntax: id ()Return value: Identity value of type The function accepts exactly one argument i.e. the name of the entity whose id has to be used. This id is unique for every entity until they are referring to the same data.Id’s are merely address in the memory locations and is used internally in Python.Example Codestr_1 = "Tutorials" print(id(str_1)) str_2 = "Tutorials" print(id(str_2)) # This will return True ... Read More
125 Views
The bitonicity of an array is defined using the following syntax −To find bitonicity of an array based on its elements is −Bitonicity = 0 , initially arr[0] i from 0 to n Bitonicity = Bitonicity+1 ; if arr[i] > arr[i-1] Bitonicity = Bitonicity-1 ; if arr[i] < arr[i-1] Bitonicity = Bitonicity ; if arr[i] = arr[i-1]ExampleThe code for finding the bitonicity of an array we have used a variable called bitonicity, that changes its based on the comparison of the current and previous elements of the array. The above logic updates the bitonicity of the array and final bitonicity ... Read More
181 Views
A tetrahedron is a pyramid with triangular base i.e. it has a base that is a triangle and each side has a triangle. All the three triangles converge to a point. As in the figure, Area of Tetrahedron = (√3)a2ExampleThe code to find the area of tetrahedron uses the math library to find the square and square-root of a number using sqrt and pow methods. For calculating the area we take a floating point and the value of the expression "((sqrt(3)*a*a))" is given to it.#include #include int main() { int a= 5; float area, volume; ... Read More
1K+ Views
DFA stands for Deterministic Finite Automata. It is a finite state machine that accepts or a string based on its acceptor.Here, we are going to make a DFA that accepts a string that starts and ends with a. The input is from the set (a, b). Based on this we will design a DFA. Now, Let's discuss some valid and invalid cases that are accepted by a DFA.Strings that are accepted by DFA: ababba, aabba, aa, a.Strings that are not accepted by DFA: ab, b, aabab.ExampleThis program check for a string that starts and ends with a. This DFA will ... Read More
1K+ Views
In this article, we will see how to extract details about Youtube videos and download them in different formats using the pafy module. Head over to the link for official documentation.Install the pafy module using the following commandpip install pafyIf you run the above command, it will generate the following results on the successful installation of the module pafy.Collecting pafy Using cached https://files.pythonhosted.org/packages/b0/e8/3516f761558525b00d3eaf73744eed5c267db 20650b7b660674547e3e506/pafy-0.5.4-py2.py3-none-any.whl Installing collected packages: pafy Successfully installed pafy-0.5.4Check whether you can import the pafy module or not by running the following command.import pafyIf you found no errors then it's done. Otherwise install the following module to solve ... Read More