Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Python Programs

Python

Uploaded by

ramakant78999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Python Programs

Python

Uploaded by

ramakant78999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Python Programs

1. Python Program to Find the Factorial of a Number.


n = int (input (“Enter a number:”))
factorial = 1
if n >= 1:
for i in range (1, n+1):
factorial = factorial *i
print (“Factorial of the given number is:”, factorial)

2. Python Program to Find the Largest Among Three Numbers.


num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
num3 = int(input("Enter third number: "))
if (num1 >= num2) and (num1 >= num3):
largest = num1
elif (num2 >= num1) and (num2 >= num3):
largest = num2
else:
largest = num3
print("The largest number is", largest)

3. Python Program to Check if a Number is Odd or Even.


num=int(input("Enter any number to test whether it is odd or even: "))
if (num % 2) == 0:
print ("The number is even")
else:
print ("The provided number is odd")

4. Python Program to Find the Sum of Natural Numbers.


n = int (input ("Enter any natural number: "))
if n < 0:
print ("Wrong input. Please enter a positive number.")
else:
sum = 0
while (n > 0):
sum +=n
n -=1
print ("The sum of the natural numbers is: ", sum)
5. Python Program to Convert Fahrenheit to Celsius.
print("Enter Temperature in Fahrenheit: ")
fahren = float(input())
celi = (fahren-32)/1.8
print("\nEquivalent Temperature in Celsius: ", celi)

You might also like