(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 Code # …
(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 numbers up …
(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 obtained by …
(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). The century …