1# Program to check if a number is prime or not
2
3num = 407
4
5# To take input from the user
6#num = int(input("Enter a number: "))
7
8# prime numbers are greater than 1
9if num > 1:
10 # check for factors
11 for i in range(2,num):
12 if (num % i) == 0:
13 print(num,"is not a prime number")
14 print(i,"times",num//i,"is",num)
15 break
16 else:
17 print(num,"is a prime number")
18
19# if input number is less than
20# or equal to 1, it is not prime
21else:
22 print(num,"is not a prime number")
23
1<pre id="3346" class="graf graf--pre graf-after--p">%matplotlib inline
2import numpy as np
3import matplotlib.pyplot as plt
4fig = plt.figure()
5ax = plt.axes(projection=’3d’)</pre>
6
1theta = 2 * np.pi * np.random.random(1000)
2r = 6 * np.random.random(1000)
3x = np.ravel(r * np.sin(theta))
4y = np.ravel(r * np.cos(theta))
5z = f(x, y)
6ax = plt.axes(projection=’3d’)
7ax.plot_trisurf(x, y, z,cmap=’viridis’, edgecolor=’none’);
8
1import numpy as np
2
3import tensorflow as tf
4
5
6
7from include.data import get_data_set
8
9from include.model import model
10
11
12
13
14
15test_x, test_y = get_data_set("test")
16
17x, y, output, y_pred_cls, global_step, learning_rate = model()
18
19
20
21
22
23_BATCH_SIZE = 128
24
25_CLASS_SIZE = 10
26
27_SAVE_PATH = "./tensorboard/cifar-10-v1.0.0/"
28
29
30
31
32
33saver = tf.train.Saver()
34
35sess = tf.Session()
36
37
38
39
40
41try:
42
43 print("
44Trying to restore last checkpoint ...")
45
46 last_chk_path = tf.train.latest_checkpoint(checkpoint_dir=_SAVE_PATH)
47
48 saver.restore(sess, save_path=last_chk_path)
49
50 print("Restored checkpoint from:", last_chk_path)
51
52except ValueError:
53
54 print("
55Failed to restore checkpoint. Initializing variables instead.")
56
57 sess.run(tf.global_variables_initializer())
58
59
60
61
62
63def main():
64
65 i = 0
66
67 predicted_class = np.zeros(shape=len(test_x), dtype=np.int)
68
69 while i < len(test_x):
70
71 j = min(i + _BATCH_SIZE, len(test_x))
72
73 batch_xs = test_x[i:j, :]
74
75 batch_ys = test_y[i:j, :]
76
77 predicted_class[i:j] = sess.run(y_pred_cls, feed_dict={x: batch_xs, y: batch_ys})
78
79 i = j
80
81
82
83 correct = (np.argmax(test_y, axis=1) == predicted_class)
84
85 acc = correct.mean() * 100
86
87 correct_numbers = correct.sum()
88
89 print()
90
91 print("Accuracy on Test-Set: {0:.2f}% ({1} / {2})".format(acc, correct_numbers, len(test_x)))
92
93if __name__ == "__main__":
94
95 main()
96
97sess.close()
98
1ax = plt.axes(projection=’3d’)# Data for a three-dimensional line
2zline = np.linspace(0, 15, 1000)
3xline = np.sin(zline)
4yline = np.cos(zline)
5ax.plot3D(xline, yline, zline, ‘gray’)# Data for three-dimensional scattered points
6zdata = 15 * np.random.random(100)
7xdata = np.sin(zdata) + 0.1 * np.random.randn(100)
8ydata = np.cos(zdata) + 0.1 * np.random.randn(100)
9ax.scatter3D(xdata, ydata, zdata, c=zdata, cmap=’Greens’);
10