#!/usr/bin/env python # coding: utf-8 # In[1]: a = 11 b = 23 c = a + b print('%d + %d = %d' % (a, b, c) ) # In[2]: import math a = 2.0 b = math.sqrt(a) print('sqrt(%f) = %f' % (a, b) ) # In[5]: a = [ 1.0, 2.0, 3.0, 4.0, 5.0 ] print(a, ' --> sum =', sum(a)) b = [] for x in a: b.append(x*x) print(b) # In[6]: import numpy as np a = np.arange(0.0, 10.0, 1.0) b = a*a print(a) print(b) # In[11]: import numpy as np import matplotlib.pyplot as plt x = np.arange(0.0, 100.0, 0.1) y = np.sin(x) plt.plot(x, y) plt.xlabel('X') plt.ylabel('Y') plt.show() plt.hist(y, bins=100, range=(-1.0, 1.0)) plt.xlabel('Y') plt.ylabel('Counts') plt.show() fout = open('../data/2022ALH1_sindata.dat', 'w') for i in range(len(x)): fout.write('%10.5f %10.5f\n' % (x[i], y[i]) ) fout.close() # In[ ]: