Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

basic python programs

print("Basic Programs")
s = input("Enter your name")
print("Hi" + s)
Comment

python basic programs

print('The sum is %.1f' %(float(input('Enter first number: ')) + float(input('Enter second number: '))))
Comment

python basic programs

# Find square root of real or complex numbers
# Importing the complex math module
import cmath

num = 1+2j

# To take input from the user
#num = eval(input('Enter a number: '))

num_sqrt = cmath.sqrt(num)
print('The square root of {0} is {1:0.3f}+{2:0.3f}j'.format(num ,num_sqrt.real,num_sqrt.imag))
Comment

best python programs

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’);
Comment

python basic programs

# Python Program to calculate the square root

# Note: change this value for a different result
num = 8 

# To take the input from the user
#num = float(input('Enter a number: '))

num_sqrt = num ** 0.5
print('The square root of %0.3f is %0.3f'%(num ,num_sqrt))
Comment

best python programs

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’);
Comment

best python programs

<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>
Comment

basic python programs

print("Basic Programs")
s = input("Enter your name")
print("Hi" + s)
Comment

python basic programs

print('The sum is %.1f' %(float(input('Enter first number: ')) + float(input('Enter second number: '))))
Comment

python basic programs

# Find square root of real or complex numbers
# Importing the complex math module
import cmath

num = 1+2j

# To take input from the user
#num = eval(input('Enter a number: '))

num_sqrt = cmath.sqrt(num)
print('The square root of {0} is {1:0.3f}+{2:0.3f}j'.format(num ,num_sqrt.real,num_sqrt.imag))
Comment

best python programs

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’);
Comment

python basic programs

# Python Program to calculate the square root

# Note: change this value for a different result
num = 8 

# To take the input from the user
#num = float(input('Enter a number: '))

num_sqrt = num ** 0.5
print('The square root of %0.3f is %0.3f'%(num ,num_sqrt))
Comment

best python programs

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’);
Comment

best python programs

<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>
Comment

PREVIOUS NEXT
Code Example
Python :: nth catalan number 
Python :: virtual environment python 
Python :: django reverse vs reverse_lazy 
Python :: how to find greatest number in python 
Python :: python arrow 
Python :: PermissionError: [Errno 13] Permission denied on flask 
Python :: pandas use dict to transform entries 
Python :: how to round whole numbers in python 
Python :: declaring list size python 
Python :: pytest fixture 
Python :: django create multiple objects 
Python :: get the first item in a list in python 3 
Python :: python list remove() 
Python :: python reverse range 
Python :: set vs tuple in python 
Python :: python list operation 
Python :: telegram telethon get new user details 
Python :: python decorator class method 
Python :: object oriented python 
Python :: pandas df number of columns 
Python :: describe in python 
Python :: can we use else without if in python 
Python :: length of list in python 
Python :: sorted lambda 
Python :: matplotlib units of scatter size 
Python :: Ignoring invalid distribution -ip (c:python310libsite-packages) 
Python :: swap list 
Python :: add an item to a dictionary python 
Python :: pytest use fixture without running any tests 
Python :: interfaces in python 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =