python basic programs

Solutions on MaxInterview for python basic programs by the best coders in the world

showing results for - "python basic programs"
Sofia
22 Apr 2019
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
Louis
11 Oct 2017
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
Elsa
16 May 2017
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
Mervin
26 Feb 2016
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
Asma
19 Apr 2017
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
Alessio
16 Feb 2016
1from mpl_toolkits import mplot3d
2
queries leading to this page
python plot surfacebasic python programpython programscool advanced python scriptspython example programmatplotlib plot 3d surfacepython basic programmingex python codepython 3d plottingexample code pythonmatplotlib surface plothow to draw 3d plot in pythonall basic programs pythonpython examplebasic programs on pythonsurface plotting pythonpython codeeatpython is an example of anbig pythonsmall python programssample progams in pythonbasic programs of pythonplot 3d matplotlibpython sample programs for beginnersplot surface matplotlibpython logical programs examplestop of python programspython code exmapleimportant programming on pythonpython program examplepython big codepython plot 3dpython 5brogramsadvanced python code examplesbest python program cfg examples pythonsimple basic python programssimple python application examplebaasic python codebest python programspython programming examples advancedtop python programsis python low level languagepython 3 code exampleplot3d 28 29python complex codeinteractive 3d plot pythonpython or code examplespython beginner programspython program bigbest program to code pythonpython example programspython easiest programpython programs examplespython code advanced examplespython application example codehow to design programs pythonlong python programand code in pythonhow to build programs in python 25 in python exapmlesample code in pythonpopular programs made with pythonbest programs to use for pythonsmall python programpython is an example oflarge python codebig programs in pythonprogram in python3d plot python long python code examplepython examples program with basicsmatplotlib graph function surfaceall code python 25 in python examplebig python codesimple python program i made python programssimple program in pythoncool python programsall python programsmost useful python programspython surface plota program using pythonphyton basic codepython example code a 2a program using python3d plot matplotlibplot 3d graph in pythonpython basics programpython sample codepython 3 basic programsbasic pythonpython tutorial programspyplot surfacepython code exampepython big programspython beginners programspython long codeexamples of basic python codepython code simplea big code of pythonpython codeispython 5bprpogra 2cmpython language examplenormal program in pythonpython exmples onlinematplotlib surfacemost basic python programspython coding samplespython big programpython simple code examplessmall programs in pythonpython exaplespython 3d plotspython 2 examplesexample python codeprograms that use python code python codeexamples of full python codesimple python programscode example code pythonprograms for python codingplot 3d python ppython basic programspython examples programspython app codesprogramms in pythonpython explained in examplespython simple examplesexample python programsimple progrmas pythonbasic codes in pythonsample python codeshow to plot a surface in pythonpython basics programspython is an example of 3apython sample programsbasic programming examplessmall program in pythonpython tutorial examplesprograms built with pythonbasic prograam in pythoncan python be used for programspython progam sampleinteractive 3d plot with python python all programshow can i get all code in pythoncomplicated python programspython sampleswww simple python programpython basic codespython complex codespython concepts sample codespython programm examplespython source code examplespython simple code examplesmall python codecool python codesexample python www simple python program codespython program sample3d plot in pythonpython plot in 3dpython basics examplespython programs for beginnerspytho examplepython code basicpython where examplecode for pythonpython all basic programs3d plot in matplotlibpython full codeprogram 2a pythonbest python programmssimple programs to use in pythonpython scripting 100 examplesexamples in pythonpython 3 code examplespython coding basic examplesplot 3d matplotlib examplepython basic exampleif else easy programs with solution in pythonsimple python codesimple pythonsimple examples of python codesprogram in python examplepython program basic examplessimple python examplewhat are the best python programs3d plots in pythonplot 3d data pythoncodes pythoncool python programs to makesample python programsbasic python codepython program examples3d plot matplotlib surfacepython 3d plotfun python programspython examplepython program codespython best code examplescool python programs 27python easy programspython code samplespython program all type examplespython source code examplebasic program in pythonbasic programe in pythonpython samples and examplesinteractive 3d plot matplotlibwhat programs use pythonuseful python programsbiggest python code samplescayyer plot in 3d in pythonprograms made with pythonbasic python programs for beginnerspython programming examplessimple python program examplespython code forbest program to program pythonpython simple codebasic pyton programspython basic programsbasic programs in pythonbasic programming in pythonshort quick python code examplehow to make 3d plot in pythonpre written python codepython exammplecode example pythonall basic programs in pythonuseful python programs to makesmall code for pythonpython programhow to plot 3d in pythonpython code examplesall programs needed to make python programsexample of python codeamazing python programssimple python program for beginnerspython code examplepzthon code exampleplot 3d data matplotlibpython conde examplepython basic programs for beginnerspython basic code programs created with pythondemo python applicationbest program make by python coding3d plotting in pythonpython full exampleplot surface pltbig program in pythonpython eexamplespython 2 code examplessample python codes for find python coding examplespython programming examplepython code examplesprograms for pythoneasy python programsall python codespython 3d examplepython code samplepython code examples for beginnerssimple python applicat codeexamples of simple python programspython basic programbasic codes of pythonpy 3d plotpython 3d plot interactivematplotlib python 3d plotexamples of python codehow big is pythonsimple python programbasic programs for pythonplot 3d graph pythonpython programming code examples pdfsimple sample python codepython with exmplespython programs samplessimple programs in pythonsimple useful python programsbasic python codesplot matrix python 3dintext 3apython code exampleshow to plot a 3d graph in pythona python programfunny python programspython python basic programspython programs readypython complex programswhats the best program for pythonpython basic programs examplebest python examples programizpython simple programbasic ptyhon exaplesmost complex python programpython sample program for beginnerspython codesbasic python programshow to make 3d plot pythonpython readymade programssimply python progrmpython programming code examplespython example codessurface plot pythoncomplex python programssample complex python codematplotlib plot surfacesample python codepython big examplepython big programs examplesgeneral code in pythonpython useful programspython pysimpleexamplesstart a small python programprograms in pythonbeginner python samplewhat python programs to makepython examplessample coding in pythonpython programming codespython full programplot 3d object python 60sample python codepyhton basic code3 dimensional plot pythongood programs to make with python very big python codehow to use python programssurface plot matplotlibexample of complex python codeprograms on pythonsurface plot in matplotliball basic python programsreally cool programs pythonpython exmaple codespython programms basica 2a python codepython example full codepython free code examplespython interactive 3d plotmake a python best programpython small programs3d graph matplotlibsample cpython codeshow to plot in 3d matplotlibhow to write programs with pythoneasy programs in pythonpython simple programspython program basicpython basic programmscode for pythopython programs best python codessmall example in pythoneasy programs to code in pythonpython cidrspython basic programs