2.Write a python program to get CPU and RAM usage. import os import psutil print("The CPU usage is : ") print(psutil.cpu_percent(0.1)) # Getting % usage of virtual_memory ( 3rd field) print('RAM memory % used:', psutil.virtual_memory()[2]) # Getting usage of virtual_memory in GB ( 4th field) print('RAM Used (GB):', psutil.virtual_memory()[3]/1000000000) Output 2: The CPU usage is : 4.9 RAM memory % used: 63.1 RAM Used (GB): 3.448119296
#2. Solve the Quadratic Equations
----------------------------------------
# import complex math module
import cmath
a = 1
b = 5
c = 6
# calculate the discriminant
d = (b**2) - (4*a*c)
# find two solutions
sol1 = (-b-cmath.sqrt(d))/(2*a)
sol2 = (-b+cmath.sqrt(d))/(2*a)
print('The solution are {0} and {1}'.format(sol1,sol2))
OUTPUT
---------------------------------------
The solutions are (-3+0j) and (-2+0j)