পাইথন প্রোগ্রামিং : নাম্বার (Python Numbers in bangla)

1.9 Python Numbers

Number ডাটা টাইপের সাহায্যে সংখ্যা স্টোর করা যায়। যখনই একটি number ডাটা টাইপের মান পরিবর্তন করা হবে তখন একটি নতুন অবজেক্ট তৈরি হবে।


var1 = 1
var2 = 10

 

del statement এর সাহায্যে number অবজেক্টের রেফারেন্স ডিলেট করা যায়। যেমন,


del var1[,var2[,var3[....,varN]]]]

 

del statement এর সাহায্যে এক বা একাধিক স্টেটমেন্ট ডিলেট করা যায়। যেমন,


del var
del var_a, var_b

 

Python চার ধরনের number টাইপ সমর্থন করে। যেমনঃ

  • int = পূর্ণ সংখ্যা
  • long = আনলিমিটেড সাইজের পূর্ণসংখ্যা, এদেরকে integers এর মতই লেখা হয়, তবে শেষে একটি ছোট কিংবা বড় হাতের L থাকে। বড় হাতের L লেখার সুবিধা হচ্ছে সেটার সাথে ১ এর মিল থাকে না।
  • float = বাস্তব সংখ্যা। Float লিখার সময় অনেক ক্ষেত্রে E বা e ব্যবহৃত হয়, যা দিয়ে ১০ এর পাওয়ার বোঝায় (2.5e2 = 2.5 x 102= 250)।
  • complex = জটিল সংখ্যা, এরা a + bJ, যেখানে a এবং b হচ্ছে float এবং J এর মানে -১ এর বর্গমূল থাকে। Python প্রোগ্রামিং এ complex number এর তেমন একটা ব্যবহার নেই।

 

উদাহরনঃ

int long float complex
10 51924361L 0.0 3.14j
100 -0x19323L 15.20 45.j
-786 0122L -21.9 9.322e-36j
080 0xDEFABCECBDAECBFBAEL 32.3+e18 .876j
-0490 535633629843L -90. -.6545+0J
-0x260 -052318172735L -32.54e100 3e+26J
0x69 -4721885298529L 70.2-E12 4.53e-7j

 

Mathematical Functions

Python নিচের ফাংশনগুলোর সাহায্যে গাণিতিক হিসাব নিকাশ করে থাকে।

Function Returns ( description )
abs(x) The absolute value of x: the (positive) distance between x and zero.
ceil(x) The ceiling of x: the smallest integer not less than x
cmp(x, y) -1 if x < y, 0 if x == y, or 1 if x > y
exp(x) The exponential of x: ex
fabs(x) The absolute value of x.
floor(x) The floor of x: the largest integer not greater than x
log(x) The natural logarithm of x, for x> 0
log10(x) The base-10 logarithm of x for x> 0 .
max(x1, x2,...) The largest of its arguments: the value closest to positive infinity
min(x1, x2,...) The smallest of its arguments: the value closest to negative infinity
modf(x) The fractional and integer parts of x in a two-item tuple. Both parts have the same sign as x. The integer part is returned as a float.
pow(x, y) The value of x**y.
round(x [,n]) x rounded to n digits from the decimal point. Python rounds away from zero as a tie-breaker: round(0.5) is 1.0 and round(-0.5) is -1.0.
sqrt(x) The square root of x for x > 0

 

Random Number Functions

Random numbers গেমস, সিমুলেশন, টেস্টিং, সিকিউরিটি ইত্যাদি এপ্লিকেশনে ব্যবহৃত হয়। Python নিচের ফাংশনগুলো প্রতিনিয়ত ব্যবহার করে।

Function Description
choice(seq) A random item from a list, tuple, or string.
randrange ([start,] stop [,step]) A randomly selected element from range(start, stop, step)
random() A random float r, such that 0 is less than or equal to r and r is less than 1
seed([x]) Sets the integer starting value used in generating random numbers. Call this function before calling any other random module function. Returns None.
shuffle(lst) Randomizes the items of a list in place. Returns None.
uniform(x, y) A random float r, such that x is less than or equal to r and r is less than y

 

Trigonometric Functions

Python নিচের ফাংশনগুলোর সাহায্যে ত্রিকোণমিতৃক হিসেব-নিকাশ করে থাকে।

Function Description
acos(x) Return the arc cosine of x, in radians.
asin(x) Return the arc sine of x, in radians.
atan(x) Return the arc tangent of x, in radians.
atan2(y, x) Return atan(y / x), in radians.
cos(x) Return the cosine of x radians.
hypot(x, y) Return the Euclidean norm, sqrt(x*x + y*y).
sin(x) Return the sine of x radians.
tan(x) Return the tangent of x radians.
degrees(x) Converts angle x from radians to degrees.
radians(x) Converts angle x from degrees to radians.

Mathematical Constants

Python এ pi এবং e ধ্রুবক গুলোর ব্যবহার রয়েছে।

Permanent link to this article: http://bangla.sitestree.com/%e0%a6%aa%e0%a6%be%e0%a6%87%e0%a6%a5%e0%a6%a8-%e0%a6%aa%e0%a7%8d%e0%a6%b0%e0%a7%8b%e0%a6%97%e0%a7%8d%e0%a6%b0%e0%a6%be%e0%a6%ae%e0%a6%bf%e0%a6%82-%e0%a6%a8%e0%a6%be%e0%a6%ae%e0%a7%8d%e0%a6%ac/

Leave a Reply