Python Examples for Beginners: Python Code to Find Factorial of Number Using Recursion

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 …

Python Examples for Beginners: Python Code to Find Sum of Natural Numbers Using Recursion

Hits: 22 (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 …

Python Examples for Beginners: Python Code to Display Fibonacci Sequence Using Recursion

Hits: 12 (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 …

Python Examples for Beginners: Python Code to Display Calendar

Hits: 46 (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 …

Python Examples for Beginners: Python Code to Shuffle Deck of Cards

Hits: 17 (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’])) …

Python Examples for Beginners: Python Code to Make a Simple Calculator

Hits: 16 (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 …

Python Examples for Beginners: Python Code to Find the Factors of a Number

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 …

Python Examples for Beginners: Python Code to Find LCM

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 …

Python Examples for Beginners: Python Code to Find HCF or GCD

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 …

Python Examples for Beginners: Python Code to Find ASCII Value of Character

Hits: 5 (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 …

Python Examples for Beginners: Python Code to Add Two Numbers

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 …

Python Examples for Beginners: Python Code to Find Numbers Divisible by Another Number

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 …

Python Examples for Beginners: Python Code To Display Powers of 2 Using Anonymous Function

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 …

Python Examples for Beginners: Python Code to Find the Sum of Natural Numbers

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 …