Skip to main content

Posts

Showing posts from October, 2021

Factorial Program in Python

What is Factorial Program? Factorial Program in C: Factorial of n is   the product of all positive descending integers . Factorial of n is denoted by n!. For example: 5! = 5*4*3*2*1 = 120. How do you code a factorial for a loop in Python? num = int(input("enter a number: ")) fac = 1. for i in range(1, num + 1): fac = fac * i. print("factorial of ", num, " is ", fac) Factorial Program in Python # Python program to find the factorial of a number provided by the user. # change the value for a different result num = 7 # To take input from the user #num = int(input("Enter a number: ")) factorial = 1 # check if the number is negative, positive or zero if num < 0 : print ( "Sorry, factorial does not exist for negative numbers" ) elif num == 0 : print ( "The factorial of 0 is 1" ) else : for i in range( 1 ,num + 1 ): factorial = factorial*i print ( "The factorial of" ,num, "is" ...

Features of python

  Python   is a dynamic, high-level, free open source, and interpreted programming language. It supports object-oriented programming as well as procedural-oriented programming. In Python, we don’t need to declare the type of variable because it is a dynamically typed language. For example, x = 10 Here, x can be anything such as String, int, etc. Features in Python There are many features in Python, some of which are discussed below – 1. Easy to code: Python is a high-level programming language. Python is very easy to learn language as compared to other languages like C, C#, Javascript, Java, etc. It is very easy to code in the python language and anybody can learn python basics in a few hours or days. It is also a developer-friendly language. 2. Free and Open Source: Python language is freely available on the official website and you can download it from the given download link below click on the  Download Python  keyword. Download Python Since it is open-source, thi...