Hits: 10 (Python Tutorials for Citizen Data Scientist) Python Code to Convert Decimal to Binary, Octal and Hexadecimal In this program, you’ll learn to convert decimal to binary, octal and hexadecimal, and display it. The decimal system is the most widely used number system. However, computers only understand binary. Binary, octal and hexadecimal number systems …

Hits: 7 (Python Tutorials for Citizen Data Scientist) Python Program to Find Numbers Divisible by Another Number In this program, you’ll learn to find the numbers divisible by another number and display it. In the program below, we have used anonymous (lambda) function inside the filter() built-in function to find all the numbers divisible by 13 …

Hits: 9 (Python Tutorials for Citizen Data Scientist) Python Code To Display Powers of 2 Using Anonymous Function In this program, you’ll learn to display powers of the integer 2 using Python anonymous function. In the program below, we have used an anonymous (lambda) function inside the map() built-in function to find the powers of 2. Source …

Hits: 48 (Python Tutorials for Citizen Data Scientist) Python Code to Find the Sum of Natural Numbers In this program, you’ll learn to find the sum of n natural numbers using while loop and display it. In the program below, we’ve used an if…else statement in combination with a while loop to calculate the sum of natural …

Hits: 14 (Python Tutorials for Citizen Data Scientist) Python Code to Print the Fibonacci sequence In this program, you’ll learn to print the Fibonacci sequence using while loop. A Fibonacci sequence is the integer sequence of 0, 1, 1, 2, 3, 5, 8…. The first two terms are 0 and 1. All other terms are …

Hits: 20 (Python Tutorials for Citizen Data Scientist) Python Program to Display the multiplication Table This program displays the multiplication table of variable num (from 1 to 10). In the program below, we have used the for loop to display the multiplication table of 12. Source Code # Multiplication table (from 1 to 10) in …

Hits: 15 (Python Tutorials for Citizen Data Scientist) Python Code to Find the Factorial of a Number In this article, you’ll learn to find the factorial of a number and display it. The factorial of a number is the product of all the integers from 1 to that number. For example, the factorial of 6 …

Hits: 21 (Python Tutorials for Citizen Data Scientist) Python Code to Check Prime Number Example to check whether an integer is a prime number or not using for loop and if…else statement. If the number is not prime, it’s explained in output why it is not a prime number. A positive integer greater than 1 …

Hits: 36 (Python Tutorials for Citizen Data Scientist) Python Code to Find the Largest Among Three Numbers In this program, you’ll learn to find the largest among three numbers using if else and display it. In the program below, the three numbers are stored in num1, num2 and num3 respectively. We’ve used the if…elif…else ladder to find the largest among the three …

Hits: 21 (Python Tutorials for Citizen Data Scientist) Python Program to Check Leap Year In this program, you will learn to check whether a year is leap year or not. We will use nested if…else to solve this problem. A leap year is exactly divisible by 4 except for century years (years ending with 00). …

Hits: 35 (Python Tutorials for Citizen Data Scientist) Python Program to Check if a Number is Odd or Even In this example, you will learn to check whether a number entered by the user is even or odd. A number is even if it is perfectly divisible by 2. When the number is divided by …

Hits: 18 (Python Tutorials for Citizen Data Scientist) Python Program to Check if a Number is Positive, Negative or Zero In this example, you will learn to check whether a number entered by the user is positive, negative or zero. This problem is solved using if…elif…else and nested if…else statement. Source Code: Using if…elif…else num …

Hits: 27 (Python Tutorials for Citizen Data Scientist) Python Program to Convert Celsius To Fahrenheit In this program, you’ll learn to convert Celsuis to Fahrenheit and display it. In the program below, we take a temperature in degree Celsius and convert it into degree Fahrenheit. They are related by the formula: celsius * 1.8 = …

Hits: 13 (Python Tutorials for Citizen Data Scientist) Python Code to Convert Kilometers to Miles In this example, we’ll learn to convert kilometers to miles and display it. Example: Kilometers to Miles # Taking kilometers input from the user kilometers = float(input(“Enter value in kilometers: “)) # conversion factor conv_fac = 0.621371 # calculate miles …

Hits: 10 (Python Tutorials for Citizen Data Scientist) Python Program to Generate a Random Number In this example, you will learn to generate a random number in Python. To generate random number in Python, randint() function is used. This function is defined in random module. Source Code # Program to generate a random number between 0 and 9 …

Hits: 15 (Python Tutorials for Citizen Data Scientist) Python Code to Swap Two Variables In this example, you will learn to swap two variables by using a temporary variable and, without using temporary variable. Source Code: Using a temporary variable # Python program to swap two variables x = 5 y = 10 # To …