Server Side Programming Articles - Page 2165 of 2650

Unit Testing in Python Program using Unittest

Pavitra
Updated on 27-Sep-2019 11:30:13

206 Views

In this article, we will learn about the fundamentals of software testing by the help of unittest module available in Python 3.x. Or earlier. It allows automation, sharing of the setup and exit code for tests, and independent tests for every framework.In unit test, we use a wide variety of object oriented concepts. We will be discussing some majorly used concepts here.Testcase − It is response specific base class in accordance with a given set of inputs. We use base class of unittest i.e. “TestCase” to implement this operation.Testsuite − It is used to club test cases together and execute ... Read More

Twitter Sentiment Analysis using Python Program

Pavitra
Updated on 16-May-2022 12:23:58

491 Views

In this article, we will be learning about the twitter sentimental analysis. We will register for twitter oAuth API, install all the dependencies and finally write our sentimental analyzer script.An API(Application programming interface) is a gateway that allows you to access some servers(Twitter) internal functionality.The prerequisite is that we have a twitter account set up with verified phone number.After this, we visit the twitters website and tap on the create a new app icon. Now we fill all the credentials i.e. name and accept the developer agreement and finally click on create.Now our app is created , on the top ... Read More

Python program to print odd numbers in a list

Pavitra
Updated on 04-Jul-2020 13:00:29

3K+ Views

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven a list iterable as input, we need to display odd numbers in the given iterable.Here we will be discussing three different approaches to solve this problem.Approach 1 − Using enhanced for loopExamplelist1 = [11, 23, 45, 23, 64, 22, 11, 24] # iteration for num in list1:    # check    if num % 2 != 0:       print(num, end = " ")Output11, 23, 45, 23, 11Approach 2 − Using lambda & filter functionsExample Live Demolist1 = [11, 23, 45, 23, ... Read More

Python Program to Print Numbers in an Interval

Pavitra
Updated on 27-Sep-2019 11:06:50

528 Views

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven the starting and ending range of an interval. We need to print all the numbers in the interval given.A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.There are two for loops, first for loop is for getting the numbers in the interval and second loop for the checking whether the number is prime or not.Now let’s see the implementation.Example Live Demostart = 10 end = 29 for val in range(start, end + ... Read More

Check if a number N starts with 1 in b-base in C++

Arnab Chakraborty
Updated on 27-Sep-2019 10:49:33

205 Views

We have a number N and a base b. In this program we have to check whether the number is starting with 1 in base b or not. Suppose a number 6 is given. In binary this is 110, so it starts with 1, in base 4 also it will be 124. Here also it starts with 1.As we know, if a number N is represented in base b, b gets converted to m+1 bit sequence bm bm-1 … b0. This implies bm bm + bm-1 * bm-1 + … + b0*b0 = N. The largest number will be 2*bm ... Read More

Check if a number is Quartan Prime or not in C++

Akansha Kumari
Updated on 23-Jul-2025 18:48:18

403 Views

The Quartan primes are prime numbers that can be represented as x^4 + y^4. Where x, y > 0. Some Quartan prime numbers are {2, 17, 97, …}.In this article, we will learn how to check whether a number is Quartan Prime or not in C++. Consider the following input and output scenarios to understand the concept better: Scenario 1 Input: 17 Output: The number is Quartan Prime Explanation Here, we can represent the given number in the form of x^4 + y^4; (1)^4 + (2)^4 => 1 + 16 = 17. Scenario 2 Input: 12 Output: The number ... Read More

Check if a number is Full Prime in C++

Arnab Chakraborty
Updated on 27-Sep-2019 10:37:39

357 Views

Here we will see, how to check, whether a number is full prime or not. A number is said to be a full prime, if it is prime, and all of its digits are also prime. Suppose a number is 37, this is full prime. But 97 is not full prime as 9 is not a prime number.One efficient approach is that; first we have to check whether any digit is present that is not prime. Digits must be in 0 to 9. In that range 2, 3, 5 and 7 are prime, others are not prime. If all are ... Read More

Check if a number is a Pythagorean Prime or not in C++

Akansha Kumari
Updated on 24-Jul-2025 18:17:32

990 Views

The Pythagorean primes are prime numbers that can be represented in the form 4n + 1, where n is a non-negative integer. These primes have a special property as they can be expressed as the sum of two square numbers. In other words, a prime number p is called a Pythagorean prime if: p is prime, and p ≡ 1 (mod 4), i.e., when divided by 4, it leaves a remainder of 1. For example: 5 = 4x1 + 1 = 22 + ... Read More

Check if a number is a power of another number in C++

Arnab Chakraborty
Updated on 27-Sep-2019 09:13:37

620 Views

Here we will see, whether a number is power of another number or not. Suppose a number 125, and another number 5 is given. So it will return true when it finds that 125 is power of 5. In this case it is true. 125 = 53.AlgorithmisRepresentPower(x, y): Begin    if x = 1, then       if y = 1, return true, otherwise false    pow := 1    while pow < y, do       pow := pow * x    done    if pow = y, then       return true    return false ... Read More

Check if a number is a Mystery Numbers in C++

Arnab Chakraborty
Updated on 27-Sep-2019 09:07:29

755 Views

Here we will see how to check whether a number is Mystery number or not. A Mystery number is a number that can be represented by sum of two numbers, and the numbers re reverse of each other. Let us see the code to get better idea. We have to check all pairs and find the decision.Example Live Demo#include using namespace std; int revNum(int str) {    string s = to_string(str);    reverse(s.begin(), s.end());    stringstream ss(s);    int rev = 0;    ss >> rev;    return rev; } bool isMysteryNumber(int n) {    for (int i=1; i

Advertisements