The expectation of an observable $A$ with respect to the state $|\psi \rangle$ can be calculated as:
$$\langle \psi |A| \psi \rangle = Tr( \langle \psi | A| \psi \rangle) = Tr( A|\psi \rangle \langle \psi|) = Tr(A \rho) = Tr(\rho A)$$
$\rho = | \psi \rangle \langle \psi |$ is the density matrix formulation of $|\psi\rangle$.
Now, if giving a $|\psi\rangle$ and $A$, and you want to calculate $\langle \psi | A| \psi \rangle$ in Python, you can do it as follows:
import numpy as np
norm_psi = [1., 1., 1., 1.]/np.linalg.norm(psi)
A = np.matrix( '3,0,0,1; 0,-1,0,0; 0,0,-1,0; 1,0,0,1' )
print('Operator A=\n', A)
expectation = np.inner(np.conj(norm_psi).T, np.matmul(A,norm_psi) ) #Calculate <norm_psi|A|norm_psi>
print('\n expectation value calculated by <norm_psi|A|norm_psi> :\n ' , expectation)
#-------
rho = np.outer(norm_psi, np.conj(norm_psi) )
expectation = np.trace(rho*A)
print('\n expectation value calculated by Tr(rho*A):\n ' , expectation)
The output would be something like:
Operator A=
[[ 3 0 0 1]
[ 0 -1 0 0]
[ 0 0 -1 0]
[ 1 0 0 1]]
expectation value calculated by <norm_psi|A|norm_psi> :
[[1.]]
expectation value calculated by Tr(rho*A):
1.0
You can use Qiskit to do this as well. And it is quite simply if your operator $A$ is straight forward decomposition of Pauli strings, like $A = Z\otimes Z$ or $A = X \otimes Z$ etc. For instance, if
$$A = X \otimes Z = \begin{pmatrix} 0 & 1\\ 1 & 0 \end{pmatrix} \otimes \begin{pmatrix} 1 & 0\\ 0 & -1 \end{pmatrix} = \begin{pmatrix} 0 & 0 & 1 & 0\\ 0 & 0& 0 & -1 \\ 1 & 0 & 0 & 0 \\ 0 & -1 & 0 & 0 \end{pmatrix}$$
and $\psi$ is the same as previously: $|\psi \rangle = \dfrac{1}{2}\begin{pmatrix} 1 \\ 1 \\ 1\\ 1 \end{pmatrix}$. Note that this state can be prepared on a quantum circuit as:

then you can calculate the expectation as:
from qiskit import QuantumCircuit
from qiskit.aqua.operators import X, Y, Z, I
from qiskit.aqua.operators import StateFn
operator = X ^ Z #Note that ^ represents tensor product
qc = QuantumCircuit(2)
qc.h(0)
qc.h(1)
psi = StateFn(qc)
expectation = (~psi @ operator @ psi).eval()
print('expectation value is:', expectation)
output: expectation value is: 0j
Which is what you would expect by looking at the matrix form of $A$.