Hits: 9 (Python Tutorials for Citizen Data Scientist) Python Program to Illustrate Different Set Operations In this example, we have defined two set variables and we have performed different set operations: union, intersection, difference and symmetric difference. Python offers a datatype called set whose elements must be unique. It can be used to perform different …

Hits: 7 (Python Tutorials for Citizen Data Scientist) Python Code to Sort Words in Alphabetic Order In this program, you’ll learn to sort the words in alphabetic order using for loop and display it. In this example, we illustrate how words can be sorted lexicographically (alphabetic order). Source Code # Program to sort alphabetically the …

Hits: 3 (Python Tutorials for Citizen Data Scientist) Python Code to Remove Punctuation From a String This program removes all punctuation from a string. We will check each character of the string using for loop. If the character is a punctuation, empty string is assigned to it. Sometimes, we may wish to break a sentence …

Hits: 10 (Python Tutorials for Citizen Data Scientist) Python Code to Multiply Two Matrices In this example, we will learn to multiply matrices using two different ways: nested loop and, nested list comprehension. In Python, we can implement a matrix as nested list (list inside a list). We can treat each element as a row …

Hits: 32 (Python Tutorials for Citizen Data Scientist) Python Code to Add Two Matrices In this program, you’ll learn to add two matrices using Nested loop and Next list comprehension, and display it. In Python, we can implement a matrix as a nested list (list inside a list). We can treat each element as a …

Hits: 14 (Python Tutorials for Citizen Data Scientist) Python Code to Convert Decimal to Binary Using Recursion In this program, you will learn to convert decimal number to binary using recursive function. Decimal number is converted into binary by dividing the number successively by 2 and printing the remainder in reverse order. Source Code # …

Hits: 10 (Python Tutorials for Citizen Data Scientist) Python Program to Find Factorial of Number Using Recursion In this program, you’ll learn to find the factorial of a number using recursive function. 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 Find Sum of Natural Numbers Using Recursion In this program, you’ll learn to find the sum of natural numbers using recursive function. In the program below, we’ve used a recursive function recur_sum() to compute the sum up to the given number. Source Code # Python program …

Hits: 11 (Python Tutorials for Citizen Data Scientist) Python Program to Display Fibonacci Sequence Using Recursion In this program, you’ll learn to display Fibonacci sequence using a recursive function. 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 …

Hits: 43 (Python Tutorials for Citizen Data Scientist) Python Code to Display Calendar Python has a built-in function, calendar to work with date related tasks. You will learn to display the calendar of a given date in this example. In the program below, we import the calendar module. The built-in function month() inside the module takes in the year …

Hits: 15 (Python Tutorials for Citizen Data Scientist) Python Code to Shuffle Deck of Cards In this program, you’ll learn to shuffle a deck of cards using random module. Source Code # Python program to shuffle a deck of card # importing modules import itertools, random # make a deck of cards deck = list(itertools.product(range(1,14),[‘Spade’,’Heart’,’Diamond’,’Club’])) …

Hits: 14 (Python Tutorials for Citizen Data Scientist) Python Code to Make a Simple Calculator In this example you will learn to create a simple calculator that can add, subtract, multiply or divide depending upon the input from the user. Example: Simple Calculator by Using Functions # Program make a simple calculator # This function …

Hits: 10 (Python Tutorials for Citizen Data Scientist) Python Code to Find the Factors of a Number In this program, you’ll learn to find the factors of a number using the for loop. Source Code # Python Program to find the factors of a number # This function computes the factor of the argument passed …

Hits: 7 (Python Tutorials for Citizen Data Scientist) Python Code to Find LCM In this program, you’ll learn to find the LCM of two numbers and display it. The least common multiple (L.C.M.) of two numbers is the smallest positive integer that is perfectly divisible by the two given numbers. For example, the L.C.M. of …

Hits: 4 (Python Tutorials for Citizen Data Scientist) Python Program to Find HCF or GCD In this example, you will learn to find the GCD of two numbers using two different methods: function and loops and, Euclidean algorithm The highest common factor (H.C.F) or greatest common divisor (G.C.D) of two numbers is the largest positive …

Hits: 4 (Python Tutorials for Citizen Data Scientist) Python Program to Find ASCII Value of Character In this program, you’ll learn to find the ASCII value of a character and display it. ASCII stands for American Standard Code for Information Interchange. It is a numeric value given to different characters and symbols, for computers to …