0% found this document useful (0 votes)
4 views2 pages

Python Programs IKS

The document outlines various mathematical operations and methods implemented in Python, including basic arithmetic, calculating the value of Pi, converting degrees to radians, and using the Nikhilam method for multiplication. It also includes a method for squaring numbers ending in 5 and verifying the distributive property of multiplication. Each section provides example inputs and outputs for clarity.
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)
4 views2 pages

Python Programs IKS

The document outlines various mathematical operations and methods implemented in Python, including basic arithmetic, calculating the value of Pi, converting degrees to radians, and using the Nikhilam method for multiplication. It also includes a method for squaring numbers ending in 5 and verifying the distributive property of multiplication. Each section provides example inputs and outputs for clarity.
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

1.

Basic Arithmetic Operations


a = float(input("Enter 1st number: "))
b = float(input("Enter 2nd number: "))

print("Addition =", a + b)
print("Subtraction =", a - b)
print("Multiplication =", a * b)

try:
print("Division =", a / b)
except:
print("Division Error")

# Example Output:
# Enter 1st number: 5
# Enter 2nd number: 10
# Addition = 15.0
# Subtraction = -5.0
# Multiplication = 50.0
# Division = 0.5

2. Value of Pi using Aryabhata Formula

pi = (((100 + 4) * 8) + 62000) / 20000


print("Value of Pi is", pi)

# Output:
# Value of Pi is 3.1416

3. Degrees to Radians and Sine

import math

deg = float(input("Enter angle in degrees: "))


radians = deg * ([Link] / 180)
sin_value = [Link](radians)

print("Radians =", radians)


print("Sine Value =", sin_value)

# Example Output:
# Enter angle in degrees: 90
# Radians = 1.5707963267948966
# Sine Value = 1.0

4. Nikhilam Method Multiplication

def nikhilam(a, b, base):


da = a - base
db = b - base

left = a + db
right = da * db

return left * base + right

a = int(input("Enter 1st number: "))


b = int(input("Enter 2nd number: "))
base = int(input("Enter base: "))

result = nikhilam(a, b, base)


print("Result =", result)

# Example Output:
# Enter 1st number: 89
# Enter 2nd number: 63
# Enter base: 100
# Result = 5607

5. Square of Numbers Ending in 5

num = int(input("Enter a number: "))

if num % 10 != 5:
print("Number must end with 5")
else:
a = num // 10
result = (a * (a + 1)) * 100 + 25
print("Square =", result)

# Example Output:
# Enter a number: 35
# Square = 1225

6. Verify (a+b)(c+d) = ac + ad + bc + bd

a = int(input("Enter value of a: "))


b = int(input("Enter value of b: "))
c = int(input("Enter value of c: "))
d = int(input("Enter value of d: "))

lhs = (a + b) * (c + d)
rhs = (a*c) + (a*d) + (b*c) + (b*d)

print("LHS =", lhs)


print("RHS =", rhs)

# Example Output:
# Enter value of a: 1
# Enter value of b: 2
# Enter value of c: 3
# Enter value of d: 4
# LHS = 21
# RHS = 21

You might also like