fork download
  1. from math import sin
  2.  
  3. x = [.1 * i for i in range(32)]
  4. y = list(map(sin, x))
  5. a = [i for i in y if .1 < i < .6]
  6. for x, y in zip(x, y):
  7. print(f"y({x:.1f}) = {y:.4f}")
  8. print("Average: {:.4f}".format(sum(a) / len(a)))
Success #stdin #stdout 0.02s 9388KB
stdin
Standard input is empty
stdout
y(0.0) = 0.0000
y(0.1) = 0.0998
y(0.2) = 0.1987
y(0.3) = 0.2955
y(0.4) = 0.3894
y(0.5) = 0.4794
y(0.6) = 0.5646
y(0.7) = 0.6442
y(0.8) = 0.7174
y(0.9) = 0.7833
y(1.0) = 0.8415
y(1.1) = 0.8912
y(1.2) = 0.9320
y(1.3) = 0.9636
y(1.4) = 0.9854
y(1.5) = 0.9975
y(1.6) = 0.9996
y(1.7) = 0.9917
y(1.8) = 0.9738
y(1.9) = 0.9463
y(2.0) = 0.9093
y(2.1) = 0.8632
y(2.2) = 0.8085
y(2.3) = 0.7457
y(2.4) = 0.6755
y(2.5) = 0.5985
y(2.6) = 0.5155
y(2.7) = 0.4274
y(2.8) = 0.3350
y(2.9) = 0.2392
y(3.0) = 0.1411
y(3.1) = 0.0416
Average: 0.3804