Geek Culture
Published in

Geek Culture

Solving math problems using python (Quick Code-Python)

(credit: Quanta Magazine)
a = 2
b = 3
area = a*b
perimeter = 2 * (a+b)
print(area) #printing the area
O/P : 6
print(perimeter)#printing peri
O/P : 10
x = 14
y = 23
z = 6
f = 10
answer = (x — y) * z / f
print (“Result =”, answer)
O/P : Result = -5.4e = ((x - y) * z) / f
print("Result =", answer)
O/P : Result = -5.4e = (x - y) * (z / f);
print("Result =", answer)
O/P : Result = -5.4
another way to find even or odd 😂 (credit: me.me)
a = 6
b = 2
c = a%b
print(c)
O/P : 0 # number is evena = 7
b = 2
c = a%b
print(c)
O/P : 1 # number is odd
#(task 1)take a number and square itx = 6
y = x**2
print(y)
O/P : 36#(task 2) take square root of the result you get from task(1)import math #math library
z = math.sqrt(y) #using sqrt()
print(z)
O/P : 6
a = 30
area = 6 * a * a
volume = a * a * a
print(area)
O/P : 5400
print(volume)
O/P : 27000
# method number one: 
x = 6
x+=1
x+=1
x+=1
x+=1
x+=1
print(x)
O/P : 11#method number 2
x = 6
x+=5 #increment 5 times
print(x)
O/P : 11
x = 4
y = 3
z = abs(x-y) * (x+y)
print(z)
O/P : 7
Celsius = 45
Fahrenheit = 9.0/5.0 * Celsius + 32
print(Fahrenheit)
O/P : 113.0
kmph = 100
mph = 0.6214 * kmph
print(mph)
O/P : 62.13999999999999

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store