Found 26504 Articles for Server Side Programming

Python - Insert list in another list

Mohd Mohtashim
Updated on 16-May-2020 10:39:54

326 Views

A list also the extend() method, which appends items from the list you pass as an argument. extend() − Python list method extend() appends the contents of seq to list. You can read more about it here "https://www.tutorialspoint.com/python/list_append.htm"Now let us see hands onExample Live Demo#append first_list = [1, 2, 3, 4, 5] second_list = [6, 7, 8, 9, 10] first_list.append(second_list) # print result using append print("The list pattern using append is : " + str(first_list)) #extend third_list_ = [11, 12, 13, 14, 15] fourth_list = [16, 17, 18, 19, 20] third_list_.extend(fourth_list) print("The list pattern using extend is : " + str(third_list_))OutputThe ... Read More

Python - Increasing alternate element pattern in list

Mohd Mohtashim
Updated on 16-May-2020 10:37:27

164 Views

In this we are going to use List Comprehension with enumerate() Python provides compact syntax for deriving one list from another. These expressions are called list comprehensions.List comprehensions are one of the most powerful tools in Python. Python’s list comprehension is an example of the language’s support for functional programming concepts. You can read more about it here "www.tutorialspoint.com/python-list-comprehension" The enumerate() method adds counter to the iterable. You can read more about enumerate here " www.tutorialspoint.com/enumerate-in-python"Example Live Demo# declare list of integers my_list = [1, 2, 3] # printing the value print("Printing my_list list : " + str(my_list)) response = [value ... Read More

Program to find out the data type of user input in C++

Ayush Gupta
Updated on 01-Oct-2020 11:24:43

917 Views

In this problem, we are given input from the user. Our task is to create a program to find out the data type of user input in C++.Problem Description − We will take input from the user and check the data type of the input value.Let’s take an example to understand the problem, Example 1:Input − 34Output − It is an integerExample 2:Input − tutorialspointOutput − It is a stringSolution Approach:We will check if the input string is a number or not a number.If it is a number, we will check if it is an integer or a float value.If ... Read More

Program to find number of squares in a chessboard in C++

Ayush Gupta
Updated on 01-Oct-2020 11:28:51

2K+ Views

In this problem, we are given the size of a chessboard. Our task is to create a program to find number of squares in a chessboard in C++.Problem Description − To find the number of squares in a chessboard. We will have to calculate all the combinations of the square that are inside the chessboard i.e. we will consider squares of side 1x1, 2x2, 3x3 … nxn.Let’s take an example to understand the problem, Input: n = 4.Output: 30Squares of size 1x1 -> 16 Squares of size 2x2 -> 9 Squares of size 3x3 -> 4 Squares of size 4x4 ... Read More

Program to find number of solutions in Quadratic Equation in C++

Ayush Gupta
Updated on 01-Oct-2020 11:31:26

344 Views

In this problem, we are given a quadratic equation of type ax2 + bx + c, where a, b and c are constants. Our task is to create a program to find number of solutions in Quadratic Equation in C++.Problem Description − Here, we need to find the numbers of solutions for a quadratic equation that can have at max 2 solutions.Let’s take a few examples to understand the problem, Example 1:Input − 3x2 + 7x + 4Output − 2Explanation − the two solutions of the equation are 1 and 4/3.Example 2:Input − x2 - 4x + 4Output − 1Explanation ... Read More

Program to find N-th term of series 9, 23, 45, 75, 113… in C++

Ayush Gupta
Updated on 01-Oct-2020 11:33:07

262 Views

In this problem, we are given an integer n that denotes the nth term of the series. Our task is to create a program to find N-th term of series 9, 23, 45, 75, 113… in C++.Problem Description − Here, we need to find the nth term of the series for which we will be finding the general term of the series.The series is 9, 23, 45, 75, 113, 159, 213, …Let’s take an example to understand the problem, Input − n = 5output − 159Solution Approach, The general term of the given series isNth term = ( ((2*N + ... Read More

Program to find N-th term of series 7, 21, 49, 91, 147, 217, …… in C++

Ayush Gupta
Updated on 01-Oct-2020 11:35:06

111 Views

In this problem, we are given a number n that denotes the nth term of the series. Our task is to create a program to find the N-th term of series 7, 21, 49, 91, 147, 217, …… in C++.Problem Description - We will find the nth term of the series 7, 21, 49, 91, 147, 217, … and for that, we will deduce the general term of the series.Let’s take an example to understand the problem, Input − N = 5Output − 147Solution Approach:Let’s deduce the general term of the given series. The series is −7, 21, 49, 91, ... Read More

Program to find N-th term of series 4, 14, 28, 46, 68, 94, 124, 158, …..in C++

Ayush Gupta
Updated on 01-Oct-2020 12:17:29

602 Views

In this problem, we are given a number N. Our task is to create a program to find N-th term of series 4, 14, 28, 46, 68, 94, 124, 158, …..in C++.Problem Description − To find the Nth term of series4, 14, 28, 46, 68, 94, 124, … (N-terms),  We will find the general term of the series and calculate the value based on the value of n.Let’s take an example to understand the problem, Input − N = 5Output − 68Solution Approach:Let’s deduce the general term of the given series. The series is:4, 14, 28, 46, 68, 94, 124….We ... Read More

Program to find N-th term of series 3, 12, 29, 54, 87, … in C++

Ayush Gupta
Updated on 01-Oct-2020 12:19:11

175 Views

In this problem, we are given a number N. Our task is to create a program to find N-th term of series 3, 12, 29, 54, 87, … in C++.The series is3, 12, 29, 54, 87, 128, .... N-TermsLet’s take an example to understand the problem, Input − N = 5Output − 87Solution Approach:Let’s deduce the general term of the given series. The series is −3, 12, 29, 54, 87, 128, ....The general term of this series isTn = 4(n2 ) - 3*n + 2Using the general term formula, we can find any value of the series.For example, T8 = ... Read More

Program to find N-th term of series 3, 12, 29, 54, 86, 128, 177, 234, ….. in C++

Ayush Gupta
Updated on 15-May-2020 13:18:32

112 Views

In this tutorial, we will be discussing a program to find N-th term of series 3, 12, 29, 54, 86, 128, 177, 234, …..For this we will be provided with a number. Our task is to find the term for the given series at that particular position.Example Live Demo#include #include using namespace std; //calculating nth term of given series int nthTerm(int n) {    return 4 * pow(n, 2) - 3 * n + 2; } int main() {    int N = 4;    cout

Advertisements