python basic programs

# Program to check if a number is prime or not

num = 407

# To take input from the user
#num = int(input("Enter a number: "))

# prime numbers are greater than 1
if num > 1:
   # check for factors
   for i in range(2,num):
       if (num % i) == 0:
           print(num,"is not a prime number")
           print(i,"times",num//i,"is",num)
           break
   else:
       print(num,"is a prime number")
       
# if input number is less than
# or equal to 1, it is not prime
else:
   print(num,"is not a prime number")

3.67
4
JayDavis 85 points

                                    ax = plt.axes(projection=’3d’)# Data for a three-dimensional line
zline = np.linspace(0, 15, 1000)
xline = np.sin(zline)
yline = np.cos(zline)
ax.plot3D(xline, yline, zline, ‘gray’)# Data for three-dimensional scattered points
zdata = 15 * np.random.random(100)
xdata = np.sin(zdata) + 0.1 * np.random.randn(100)
ydata = np.cos(zdata) + 0.1 * np.random.randn(100)
ax.scatter3D(xdata, ydata, zdata, c=zdata, cmap=’Greens’);

3.67 (3 Votes)
0
3.86
7

                                    from mpl_toolkits import mplot3d

3.86 (7 Votes)
0
4.17
6

                                    <pre id="3346" class="graf graf--pre graf-after--p">%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = plt.axes(projection=’3d’)</pre>

4.17 (6 Votes)
0
0
0
Mark Adler 95 points

                                    theta = 2 * np.pi * np.random.random(1000)
r = 6 * np.random.random(1000)
x = np.ravel(r * np.sin(theta))
y = np.ravel(r * np.cos(theta))
z = f(x, y)
ax = plt.axes(projection=’3d’)
ax.plot_trisurf(x, y, z,cmap=’viridis’, edgecolor=’none’);

0
0
3.75
8
MerelyBlink 105 points

                                    import numpy as np
 
import tensorflow as tf
 
 
 
from include.data import get_data_set
 
from include.model import model
 
 
 
 
 
test_x, test_y = get_data_set("test")
 
x, y, output, y_pred_cls, global_step, learning_rate = model()
 
 
 
 
 
_BATCH_SIZE = 128
 
_CLASS_SIZE = 10
 
_SAVE_PATH = "./tensorboard/cifar-10-v1.0.0/"
 
 
 
 
 
saver = tf.train.Saver()
 
sess = tf.Session()
 
 
 
 
 
try:
 
    print("
Trying to restore last checkpoint ...")
 
    last_chk_path = tf.train.latest_checkpoint(checkpoint_dir=_SAVE_PATH)
 
    saver.restore(sess, save_path=last_chk_path)
 
    print("Restored checkpoint from:", last_chk_path)
 
except ValueError:
 
    print("
Failed to restore checkpoint. Initializing variables instead.")
 
    sess.run(tf.global_variables_initializer())
 
 
 
 
 
def main():
 
    i = 0
 
    predicted_class = np.zeros(shape=len(test_x), dtype=np.int)
 
    while i < len(test_x):
 
        j = min(i + _BATCH_SIZE, len(test_x))
 
        batch_xs = test_x[i:j, :]
 
        batch_ys = test_y[i:j, :]
 
        predicted_class[i:j] = sess.run(y_pred_cls, feed_dict={x: batch_xs, y: batch_ys})
 
        i = j
 
 
 
    correct = (np.argmax(test_y, axis=1) == predicted_class)
 
    acc = correct.mean() * 100
 
    correct_numbers = correct.sum()
 
    print()
 
    print("Accuracy on Test-Set: {0:.2f}% ({1} / {2})".format(acc, correct_numbers, len(test_x)))
 
if __name__ == "__main__":
 
    main()
 
sess.close()

3.75 (8 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
programs that use python all basic programs in python best program to code python python programs all basic programs python python all basic programs really cool programs python basic programs for python how big is python make a python best program best programs to use for python programs built with python popular programs made with python python big programs examples all basic python programs what programs use python big program in python a big code of python best python program best program make by python coding python programs useful python programs to make most basic python programs whats the best program for python cool python programs what are the best python programs can python be used for programs cool python programs' easy python programs funny python programs is python low level language basic programs of python best program to program python all programs needed to make python programs useful python programs python all programs all python programs if -else easy programs with solution in python python is an example of: intext:python code examples python example full code ppython basic programs python 3 code example simple basic python programs python tutorial programs a * program using python a program using python python with exmples python program codes python basic programs example long python program python easiest program large python code python coding basic examples python programs examples cool advanced python scripts example code python biggest python code sample basic programming examples python code sample short quick python code example pzthon code example python free code examples python basic programms examples of basic python code python exmples online best python programs complicated python programs example of python code python codeis simple examples of python codes python programm examples python explained in examples python complex programs simple python program examples simple python application example python simple examples python samples and examples python samples simple progrmas python small python code small python program python eexamples python complex code example of complex python code python best code examples python app codes best python programms complex python programs long python code example all python codes python basic programs for beginners sample python codes pre written python code python progam sample programs in python program * python program in python example python basics program python basics programs small code for python basic programs in python demo python application python exmaple codes most complex python program best python examples programiz python source code examples python language example python code examples for beginners python simple code example code example python cool python codes python programms basic basic python codes python big example basic prograam in python important programming on python python small programs big python code python basic example python programs ready python example www.simple python program All code python python tutorial examples simple python example basic programe in python python full program python programming examples advanced python full example phyton basic code Python big code python program all type examples basic programs on python www.simple python program codes python sample programs for beginners python sample program for beginners python programming code examples pdf python long code python code samples general code in python python readymade programs python exaples example python program basic ptyhon exaples basic codes in python python 2 examples python 2 code examples python basics examples simply python progrM basic pyton programs small example in python most useful python programs python code simple python PySimpleexamples code for pytho good programs to make with python code python code -cfg examples python big programs in python simple programs to use in python python easy programs python [prpogra,m python programming examples simple python basic python program python application example code sample python codes for find sample coding in python programms in python code for python pytho example python examples program with basics python is an example of python simple programs python coding samples small python programs pyhton basic code sample cpython codes python basic program basic python code code example code python ex python code and code in python python = example python simple code examples basic codes of python python program basic small program in python python code basic small programs in python simple program in python python programming codes python program sample how can i get all code in python python [rograms easy programs to code in python python concepts sample codes very big python code easy programs in python python 3 code examples python conde example simple python applicat code sample complex python code python basic programming `sample python code python programs samples python basic code python examples programs python exammple normal program in python python logical programs examples python basic codes python programming code examples simple useful python programs basic python programs for beginners python cidrs beginner python sample python codeeat what python programs to make example python code baasic python code simple python code python code for python source code example examples of full python code examples of python code python code examples examples in python python example program sample python code codes python python program basic examples python code advanced examples python where example python program example a python program python big programs python scripting 100 examples simple programs in python python full code python complex codes python coding examples simple python program python or code examples python example code simple python program i made cool python programs to make advanced python code examples python sample code amazing python programs python program examples python programs for beginners example python python programs % in python example programs on python python codes % in python exapmle python code exmaple python code example python beginner programs python simple code python example python code examples python example programs sample progams in python python sample programs simple sample python code a* python code python example codes python code exampe basic programming in python python simple program start a small python program best python codes simple python program for beginners python programming example sample python programs python examples Python is an example of an python basic programs basic python programs python program simple python programs sample code in python python program big
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source