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

PREVIOUS NEXT
Code Example
Python :: pow() Function Function in python 
Python :: how to write a python comment 
Python :: how to make a window python 
Python :: calculate quantiles python 
Python :: check if item exists in list python 
Python :: django email change sender name 
Python :: Looping and counting in python 
Python :: get first element of tuple python 
Python :: how to count substring in a string in python 
Python :: django login url 
Python :: python how to extract a string from another string 
Python :: python os get dir path 
Python :: django form field class 
Python :: beautifulsoup get img alt 
Python :: get files in directory 
Python :: openmp for loop 
Python :: what are args and kwargs in python 
Python :: add timestamp csv python 
Python :: get particular columns from dataframe 
Python :: how to sort values by index pandas 
Python :: pandas get highest values row 
Python :: change column names pandas 
Python :: calculate the shortest path of a graph in python 
Python :: pandas dataframe caption 
Python :: changing names of column pandas 
Python :: array with zeros python 
Python :: newline in python gives an extra one 
Python :: python relative import 
Python :: Python Requests Library Delete Method 
Python :: Change one value based on another value in pandas 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =