Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
# Euler method in Python -
from __future__ import division
from math import exp
import matplotlib.pyplot as plt
import numpy as np
h=0.1
x0=0
y0=0
xmax=0.5
x=x0
y=y0
print "Euler method\n"
puntsEuler=[]
while x<=xmax:
puntsEuler.append((x,y))
print x,y
k1=(-2*x*y+2*x*exp(-x**2))
y = y + h*k1
x = x + h
# dibuixant els punts i la solucio
def f(z):
return np.exp(-z*z)*z*z
te, eu = zip(*puntsEuler)
t1 = np.arange(x0, xmax, h/10)
plt.plot(te,eu,'b-',marker='o')
plt.plot(t1,f(t1),'r')
plt.show()
# Hello World program in Python
print "Hello World!\n"
m=2;
for k in range(0,2*m):
x=44331*k/(2*m);
r=(6356800+x)/(6378100+x);
e=(1-r*r)**(0.5);
arctane=log.math(e);
print arctane;
# to write use print
name = "Drew" # assinging variables
number = (5 + 20) # MATH
print name
print number
a=b=c=4.7 # multiple variables
print a
print b
print c
print "1"
d,e,f = 1,"poo", 7
print f
print d
print e
#""\n\n" to skip
print "\n\nskip"
#var = 10
#del var
#print var #(^ makes error)
fork = "SpoonFork"
print "\n"
print fork
print fork[0:5]
print fork *8
print "\n"
ist = [123, "wert"]
lis = [12,"13k", 2345]
print lis
print ist + lis
dict = {}
dict['one'] = "This is one"
dict[2] = "This is two"
tinydict = {'name': 'john','code':6734, 'dept': 'sales'}
print dict['one'] # Prints value for 'one' key
print dict[2] # Prints value for 2 key
print tinydict # Prints complete dictionary
print tinydict.keys() # Prints all the keys
print tinydict.values() # Prints all the values
0