This is how you can remove duplicates from a List in Python.
[mai mult...]JavaScript program to find the square root
In this example, you’ll learn to write a program to find the square root of a number in JavaScript.
[mai mult...]Javascript program to convert celsius to fahrenheit
You can convert the celsius value to fahrenheit by using the formula:
fahrenheit = celsius * 1.8 + 32
[mai mult...]JavaScript program to convert kilometers to miles
We know that 1 kilometer is equal to 0.621371 miles.
So to convert kilometers to miles, you can use the formula:
miles = kilometers * 0.621371
[mai mult...]JavaScript program to swap two variables using es6(ES2015) destructuring assignment
Here, a new es6 feature, called destructuring assignment [a, b] = [b, a], is used to swap the value of two variables. If [a, b] = [1, 2, 3], the value of a will be 1 and value of b will be 2.
First a temporary array [b, a] is created. Here the value of [b, a] will be [2, 4].
The destructuring of the array is done, i.e [a, b] = [2, 4].
As a result, the value of the variables are swapped.
JavaScript program to swap two variables using a temporary variable
We created a temp variable to store the value of a temporarily.
We assigned the value of b to a.
The value of temp is assigned to b
As a result, the value of the variables are swapped.
Python program to display the multiplication table
This program displays the multiplication table of variable num
[mai mult...]Python program to check if a number is positive, negative or 0
num = float(input(“Enter a number: “))
if num > 0:
print(“Positive number”)
elif num == 0:
print(“Zero”)
else:
print(“Negative number”)
Python program to check if a number is odd or even
A number is even if it is perfectly divisible by 2. When the number is divided by 2, we use the remainder operator %
to compute the remainder. If the remainder is not zero, the number is odd.
Python program to print all prime numbers in an interval
A positive integer greater than 1 which has no other factors except 1 and the number itself is called a prime number.
2, 3, 5, 7, etc. are prime numbers as they do not have any other factors. But 6 is not prime (it is composite) since, 2 x 3 = 6.
[mai mult...]