Python .g3g3
Python .g3g3
By:- Gayathri MJ
Program that adds two numbers
"""
@author: Gayathri MJ
"""
Output
Enter number one: 2
"""
@author: Gayathri MJ
"""
userInput = int(input("Do you want to convert \n (1)Celcius to farhenheit \n (2) Farhenheit to Celcius
\n Your Choice: "))
if userInput == 1:
fahrenheit = (celcius*1.8) + 32
elif userInput == 2:
else:
print("Invalid Option")
Output
Do you want to convert
(1)Celcius to farhenheit
Your Choice: 1
"""
@author: Gayathri MJ
"""
# Square root
import math
Output
Enter the number: 16
"""
@author: Gayathri MJ
"""
import math
a = float(input("Input a : "))
b = float(input("Input b : "))
c = float(input("Input c : "))
s = (a+b+c)/2
area = math.sqrt((s*(s-a)*(s-b)*(s-c)))
Output
Input a : 4
Input b : 5
Input c : 6
"""
@author: Gayathri MJ
"""
discriminant = (b**2)-(4*a*c)
sol1 = (-b-cmath.sqrt(discriminant)/(2*a))
sol2 = (-b+cmath.sqrt(discriminant)/(2*a))
Output
Enter coefficient of x squared (a): 1
"""
@author: Gayathri MJ
"""
import numpy
y = numpy.sin(t)
plt.plot(t,y)
plt.xlabel('time')
plt.ylabel('Amplitude')
plt.legend('Sint')
plt.show()
Output
Program that plots ideal gas equation
"""
@author: Gayathri MJ
"""
import numpy
T = 2.10505
R = 8.314
v = numpy.linspace(.1,1,1000)
p = R*T/v
plt.plot(v,p)
plt.xlabel("Volume")
plt.ylabel("Pressure")
plt.legend("P = RT/V")
plt.show()
Output
Program that plots Wander vaals equation
# -*- coding: utf-8 -*-
"""
@author: Gayathri MJ
"""
import numpy
a = 5.489
b = 0.063
T = 3.10505
R = 8.314
v = numpy.linspace(.1,1,1000)
p = R*T/(v-b)-a/v**2
plt.plot(v,p)
plt.xlabel("Volume")
plt.ylabel("Pressure")
plt.show()
Output
Program that plots projectile motion
# -*- coding: utf-8 -*-
"""
@author: Gayathri MJ
"""
#Projectile motion
import numpy
v0 = 5
g = 9.81
t = numpy.linspace(0,1,1000)
y = v0*t - 0.5*g*t**2
largest_height = y[0]
largest_height = y[i]
plt.plot(t,y)
plt.xlabel('Time (s)')
plt.ylabel('Height (m)')
plt.show()
Output