martedì 16 marzo 2010

how to calculate trigonometry with python

for that kind of jobs I can tell you it's more useful and faster C++ extensions than pure Python, but if you want do that in pure Python... I'll show you how to do that

#!/usr/bin/python
def ask():
...import math as m
...value_deg=int(raw_input("insert an angle value in degrees"))
...x=value_deg #I use that to write less...
...""" the formula with you can convert a degrees value in radians is
...deg:360=rad:2*PI --> rad=((deg*2/360)*PI) --> rad=((deg/180)*PI) """
...value_rad=(x/180.0)*3.14159) #I used 3.14159 for PI
...""" the sin(), cos() and tan() accept radians values only, and I round the
...printed value to five numbers"""
...#print sin of value_rad
...print round(m.sin(value_rad), 5)
...#print cos of value_rad
...print round(m.cos(value_rad), 5)
...#print tan of value_rad
...print round(m.tan(value_rad), 5)

I hope it's useful... Stay tuned!

domenica 14 marzo 2010

how to create 2d arrays in python

#!/usr/bin/python
def doubleDimArrays():
""" this function creates a 2D array containing all boolean values and return it """
BiDimArray=range(0,2)
for i in BiDimArray:
BiDimArray[i]=range(0,2)
for j in BiDimArray[i]:
BiDimArray[i][j]=False
return BiDimArray

>>>a=doubleDimArrays()
>>>print a
[[False, False], [False, False]]

domenica 7 marzo 2010

advices to developing newbies

There my advices to newbies:

Everything you listen or read on Internet, books and tutorials is THE TRUTH!
You've to try, make experience, accumulate knowledge... Do it and you'll be a good programmer. Ehm, you mustn't believe in everything I said! :D

Other infos, in Italian, are there

sabato 6 marzo 2010

Hello!!!

NORMAL TEXT:
So, you understand I'm a programmer... Yeah, you've got the point! I created this blog to say all that I knew, I know and I'll know about PC, programming, Mobile, Console, Music...
I'm studing Python, C++, Qt Gui programming, Embedded microprocessors programming, so you can see C++ and Python codes, also Tips&Tricks about Qt and news about technology!

ENJOY YOURSELF!!!


#!/usr/bin/python
#i'm too lazy to hand code that... :D
import __hello__
Hello world...