0% found this document useful (0 votes)
9 views11 pages

Python Programs for Basic Calculations

The document contains ten Python programs that perform various tasks, including adding two numbers, calculating simple interest, finding the factorial of a number, determining the length of a word, printing a multiplication table, checking if a number is odd or even, identifying if a number is positive or negative, calculating the square of a number, checking for prime numbers, and converting Celsius to Fahrenheit. Each program includes user input prompts and prints the corresponding output. The programs demonstrate basic programming concepts and operations in Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views11 pages

Python Programs for Basic Calculations

The document contains ten Python programs that perform various tasks, including adding two numbers, calculating simple interest, finding the factorial of a number, determining the length of a word, printing a multiplication table, checking if a number is odd or even, identifying if a number is positive or negative, calculating the square of a number, checking for prime numbers, and converting Celsius to Fahrenheit. Each program includes user input prompts and prints the corresponding output. The programs demonstrate basic programming concepts and operations in Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

Program to add two Number


Input :-
# in this program the user can input by own
a=int(input("enter the first number :-"))
b=int(input("enter the second number:-"))
#the sum function
c=a+b
print("the sum of desired number is :-",c)

output:-
[Link] to find the Simple Interest
INPUT:-
P = float(input("Enter the principal amount:- "))
R = float(input("Enter the rate of interest:- "))
T = float(input("Enter the time in years:- "))
# formula of simple interest
SI = (P * R * T) / 100
print("Simple Interest =", SI)

output:-
[Link] to find factorial of a
number
Input:-
n = int(input("Enter a number: "))
factorial = 1
#here we use range to make factorial
for i in range(1, n + 1):
factorial *= i
print("Factorial of", n, "is", factorial)

output:-
[Link] to find length of a word
Input:-
#to find of a number we use len
a=(input(" enter the name:-"))
print("the length in a is ",len(a))

Output:-
[Link] to print Table
Input:-
num = int(input("Enter a number: "))

print("Multiplication Table of", num)

for i in range(1, 11):


print(num, "x", i, "=", num * i)

output:-
[Link] to find number is odd or
even
Input:-
n = int(input("Enter a number: "))

if n % 2 == 0:
print("Even number")
else:
print("Odd number")

output:-
[Link] to find number is Positive
or Negative
Input:-
n = int(input("Enter a number: "))
if n > 0:
print("Positive")
elif n < 0:
print("Negative")
else:
print("Zero")
output:-
[Link] to find the square of a
number
Input:-

n = int(input("Enter number: "))


print("Square =", n * n)

output:-
[Link] to check prime number
Input:-
num = int(input("Enter a number: "))
if num > 1:
for i in range(2, num):
if num % i == 0:
print("Not Prime")
break
else:
print("Prime Number")
else:
print("Not Prime")

output:-

[Link] to convert Celsius to


Fahrenheit
Input:-
c = float(input("Enter temperature in Celsius: "))
f = (c * 9/5) + 32
print("Fahrenheit =", f)

output:-

You might also like