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.
Tutorialspoint

euler2

# 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()

Execute Python Online

# Hello World program in Python

nimi1 = "Mihkel"
nimi2 = "Mari"
tervitus = "Tere, " + nimi1 + " ja " + nimi2 + "!"
print(tervitus)

Execute Python Online

import cmath
num = int(input("enter the number"))
sq_root = cmath.sqrt(num)
print('*****The squareroot of {0} is {1}'.format(num, sq_root))

Execute Python Online

from PIL import Image
import sys


def get_data(height, width, interval, datalen, start):
    # first line: 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0 ...
    data = []
    raw_line = [0] * interval
    raw_line.extend([1] * datalen)
    packlen = interval + datalen
    raw = raw_line * (int(width / packlen) + 2)
    start = packlen - start
    for i in range(height):
        if start > packlen:
            start = (start % packlen)
        data.extend(raw[start:start + width])
        start += 1
    return data


def get512():
    return get_data(512, 512, 13, 7, 3)


def get256():
    return get_data(256, 256, 13, 7, 3)


def get128():
    return get_data(128, 128, 13, 7, 3)


def get48():
    return get_data(48, 48, 5, 5, 2)


raw_data = {
    # 48: get48,
    128: get128,
    256: get256,
    512: get512
}


def transparent(point):
    if point[3] != 255 and (66 < point[0] < 70) and (66 < point[1] < 70) \
            and (62 < point[2] < 66):
        return True
    return False


def rec(x, i):
    a, b, c, d = x
    a = int((a - 68 * i) / (1 - i))
    b = int((b - 68 * i) / (1 - i))
    c = int((c - 64 * i) / (1 - i))
    return (a, b, c, d)


def unmark(filename):
    im = Image.open(filename)
    im = im.convert("RGBA")
    kk = im.load()
    func = raw_data.get(im.size[0])
    if not func:
        print ("NOT SUPPORT SIZE (128, 256, 512)")
        sys.exit()

    print ("SIZE: ", im.size)
    nodes = func()

    for index, node in enumerate(nodes):
        if node == 0:
            continue

        i = index % im.size[1]
        j = index / im.size[1]

        if transparent(kk[i, j]):
            kk[i, j] = (0, 0, 0, 0)
        else:
            if (i > 1 and nodes[index - 1] == 0) or (j < im.size[1] - 1 and nodes[index + 1] == 0):
                kk[i, j] = rec(kk[i, j], 0.015)
            elif (i > 2 and nodes[index - 2] == 0) or (j < im.size[1] - 2 and nodes[index + 2] == 0):
                kk[i, j] = rec(kk[i, j], 0.065)
            else:
                kk[i, j] = rec(kk[i, j], 0.073)

    new_name = filename.lower().replace(".png", ".new.png")

    print ("NEW: ", new_name)
    im.save(new_name, "PNG")


def show(x, n):
    for i in range(n):
        for j in range(n):
            print (x[i * n + j]),
        print


if __name__ == '__main__':
    unmark(sys.argv[1])

Execute Python Online

# 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;

Python Help

# 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

First project

# Hello World program in Python
    
print "Hello World!\n"

myproject

x=10;
y=25;
z=x+y;

print "Sum of x+y =", z;
for i in range(1,5):
    print "#",i
    
    
    

input

print "Hello World!\n"
num_1 = int (input ("Введите 1 число: \n"))
num_2 = int (input ("Введите 2 число: \n"))
num_3 = int (input ("Введите 3 число: \n"))
res = num_1 + num_2 + num_3
print ("Добавление чисел: \n", res)
res = num_1 - num_2 - num_3
print ("Вычитание чисел: \n", res)
print ("Умножение чисел: \n", num_1 * num_2 * num_3)
print ("Деление чисел: \n", num_1 / num_2 / num_3)
print ("Остаток при делении чисел: \n", num_1 % num_2 % num_3)

Execute Python Online

#!/usr/bin/python
sample = "sarranya"
print 'sample'

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.