Rajesh SinghNov 11, 20201 minPython program to print sum of n natural numbersa=int(input("Enter a number: ")) sum = 0 while(a > 0): sum=sum+a a=a-1 print("The sum of natural numbers is",sum)
Rajesh SinghNov 10, 20201 minPython Program using function to calculate addition, substraction, multiplication and divisiondef add(a,b): print("Addition of two numbers", a+b) def sub(a,b): print("Subtraction of Two numbers",a-b) def mul(a,b): print("Multiplica...
Rajesh SinghNov 5, 20202 minPython Programs to print pattern Number, Pyramid, Star, Diamond and Letter PatternWrite a python program for given Numbers Pattern using a for loop 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 Program: for num in range(6): for i in ra...
Rajesh SinghMar 31, 20201 minPython Program for Cube of a Number using FunctionsProgram: def cube(a): print("The Cube of given number", a*a*a) b = int(input(" Enter any number : ")) cube(b) Output: Please Enter any n...
Rajesh SinghMar 31, 20201 minPython Program to add Two numbersProgram: num1 = int (input(" Please Enter the First Number: ")) num2 = int (input(" Please Enter the second number: ")) sum = num1+num2 p...
Rajesh SinghMar 31, 20201 minPython Program to find roots of a Quadratic EquationProgram: a = int(input("Enter the value of a : ")) b = int(input("Enter the value of b : ")) c = int(input("Enter the value of c : ")) di...
Rajesh SinghMar 31, 20201 minPython Program to Check a Number is a Perfect NumberA perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For instance, 6 ha...
Rajesh SinghMar 31, 20201 minPython program to swap two numbersa=int(input("Enter The First Number :")) b=int(input("Enter The Second Number :")) print("Before SWAPPING a=",a," b=",b) c=a a=b b=c prin...
Rajesh SinghMar 29, 20201 minPython Program to Check number is Palindrome or NotA palindromic number is a number that remains the same when its digits are reversed. Like 121. Program: n=int(input("Enter number:")) a=n...
Rajesh SinghMar 29, 20201 minPython Program to Check Armstrong NumberArmstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong n...
Rajesh SinghMar 29, 20201 minPython Program to Print the Fibonacci sequencePython Program to Print the Fibonacci sequence Using While Loop num = int(input("How many terms? ")) a, b = 0, 1 i = 0 if num <= 0: print...
Rajesh SinghMar 29, 20201 minWrite a Python program to print even numbers between 1 to 100.Python program to print even numbers between 1 to 100. Program: for num in range(1,100): if num%2==0: print (num) num=num+1 Output: 2 4 6...
Rajesh SinghMar 26, 20201 minWrite a Python Program to Display the multiplication Table ?Python Program to Display the multiplication Table num = int(input("Enter number: ")) for i in range(1, 11): print(num, 'x', i, '=', num*...
Rajesh SinghMar 26, 20201 minWrite a Python Program to Check if a Number is Positive, Negative or 0 ?Python Program to Check if a Number is Positive, Negative or 0 by Nested if num = float(input("Enter a number: ")) if num >= 0: if num ==...
Rajesh SinghMar 26, 20201 minWrite a Python program to check if year is a leap year or not?Python program to check if year is a leap year or not year = int(input("Enter Year: ")) if year % 4 == 0 and year % 100 != 0: print(ye...
Rajesh SinghMar 26, 20201 minWrite a Python Program to Find the Factorial of a Number?Python Program to Find the Factorial of a Number num = int(input("Enter a number: ")) factorial = 1 # check if the number is negative,...
Rajesh SinghMar 26, 20201 minWrite a Python Program to Check Prime Number?Python Program to Check Prime Number num = int(input("Enter any number: ")) if num > 1: for i in range(2, num): if num % i == 0: print("...
Rajesh SinghMar 26, 20201 minWrite a Python Program to Check a Number is Odd or Even ?Python Program to Check a Number is Odd or Even num = int(input("Enter a number: ")) if (num % 2) == 0: print("{0} is Even".format(num)) ...
Rajesh SinghMar 26, 20201 minTo find the largest number among the three input numbers in Python program?To find the largest number among the three input numbers a = int(input("Enter first number: ")) b= int(input("Enter second number: ")) c ...