পাইথন প্রোগ্রামিং : তালিকা (Python Lists in Bangla)

1.11 Python Lists

Python এর সবচেয়ে বেসিক ডাটা স্ট্রাকচার হচ্ছে sequence. এর প্রতিটি উপাদান এর সাথে একটি নাম্বার assign করা থাকে, যা এর অবস্থান/ ইন্ডেক্স নির্দেশ করে। সর্ব প্রথম ইন্ডেক্স হচ্ছে ০, তারপরেরটা ১, তারপরেরটা ২… ইত্যাদি !

Python এ ৬ ধরনের built-in sequence আছে, তাদের মধ্যে সবচেয়ে প্রচলিত হচ্ছে lists আর tuples। sequence টাইপের সাহায্যে indexing, slicing, adding, multiplying, ও checking করা যায়। এছাড়াও Python এর বিল্ট-ইন ফাংশনের সাহায্যে যেকোনো sequence এর দৈর্ঘ্য হিসেব করা যায় যার সাহায্যে দীর্ঘতম ও ক্ষুদ্রতম প্রোসেস বের করা যায়।

 

Python Lists

List হচ্ছে Python এর সবচেয়ে বৈচিত্রপূর্ণ ডাটা টাইপ, যেটি থার্ড ব্র্যাকেট [ ] এর ভেতর কমার সাহায্যে উপাদান সহ প্রকাশ করা হয়। List এর উপাদানগুলো একরকম ডাটা টাইপ হবার প্রয়োজন নেই। যেমন,


list1 = ['physics', 'chemistry', 1997, 2000];
list2 = [1, 2, 3, 4, 5 ];
list3 = ["a", "b", "c", "d"];

 

স্ট্রিং এর মত, লিস্টের মান ০ থেকে শুরু হয়, এবং একে sliced, concatenated করা যায়।

 

Accessing Values in Lists

List এর মান print করতে [ ] ও ইনডেক্স নাম্বার (০, ১ ইত্যাদি) ব্যবহার করা হয়। যেমন,


#!/usr/bin/python

list1 = ['physics', 'chemistry', 1997, 2000];
list2 = [1, 2, 3, 4, 5, 6, 7 ];

print "list1[0]: ", list1[0]
print "list2[1:5]: ", list2[1:5]

 

উপরের প্রোগ্রামটির রেসাল্ট হবে,


list1[0]:  physics
list2[1:5]:  [2, 3, 4, 5]


 

Updating Lists

একটি list এর এক বা একাধিক উপাদান এর মান নিচের মত আপডেট করা যায়ঃ


#!/usr/bin/python

list = ['physics', 'chemistry', 1997, 2000];

print "Value available at index 2 : "
print list[2]
list[2] = 2001;
print "New value available at index 2 : "
print list[2]

 

এখানে list[2] মান দ্বিতীয় স্টেটমেন্ট এ আপডেট করা হয়েছে। উপরের কোডটি রান করালে নিচের ফলাফল আসবে।


Value available at index 2 :
1997
New value available at index 2 :
2001


 

Delete List Elements

del statement এর সাহায্যে একটি নির্দিষ্ট উপাদান ডিলেট করা যায়, remove() মেথডের সাহায্যে কোন অজানা উপাদান ডিলেট করা যায়, যেমনঃ


#!/usr/bin/python

list1 = ['physics', 'chemistry', 1997, 2000];

print list1
del list1[2];
print "After deleting value at index 2 : "
print list1

 

উপরের প্রোগ্রামটির রেসাল্ট হবে,


['physics', 'chemistry', 1997, 2000]
After deleting value at index 2 :
['physics', 'chemistry', 2000]

 

Basic List Operations

Python Expression Results Description
len([1, 2, 3]) 3 Length
[1, 2, 3] + [4, 5, 6] [1, 2, 3, 4, 5, 6] Concatenation
[‘Hi!’] * 4 [‘Hi!’, ‘Hi!’, ‘Hi!’, ‘Hi!’] Repetition
3 in [1, 2, 3] True Membership
for x in [1, 2, 3]: print x, 1 2 3 Iteration

 

Indexing, Slicing, and Matrixes

মনে করি,


L = ['spam', 'Spam', 'SPAM!']

 

 

Python Expression Results Description
L[2] ‘SPAM!’ Offsets start at zero
L[-2] ‘Spam’ Negative: count from the right
L[1:] [‘Spam’, ‘SPAM!’] Slicing fetches sections

 

Built-in List Functions & Methods:

Python এ নিচের List Functions গুলো ব্যবহৃত হয়ঃ

SN Function with Description
1 cmp(list1, list2)
Compares elements of both lists.
2 len(list)
Gives the total length of the list.
3 max(list)
Returns item from the list with max value.
4 min(list)
Returns item from the list with min value.
5 list(seq)
Converts a tuple into list.

 

Python নিচের list methods গুলো ব্যবহার করে।

SN Methods with Description
1 list.append(obj)
Appends object obj to list
2 list.count(obj)
Returns count of how many times obj occurs in list
3 list.extend(seq)
Appends the contents of seq to list
4 list.index(obj)
Returns the lowest index in list that obj appears
5 list.insert(index, obj)
Inserts object obj into list at offset index
6 list.pop(obj=list[-1])
Removes and returns last object or obj from list
7 list.remove(obj)
Removes object obj from list
8 list.reverse()
Reverses objects of list in place
9 list.sort([func])
Sorts objects of list, use compare func if given

 

পাইথন প্রোগ্রামিং : স্ট্রিং (Python Strings in Bangla)

1.10 Python Strings

Accessing Values in Strings

নিচের কোডটি লক্ষ্য করি,


#!/usr/bin/python

var1 = 'Hello World!'
var2 = "Python Programming"

print "var1[0]: ", var1[0]
print "var2[1:5]: ", var2[1:5]

 

উপরের কোডটি রান করালে নিচের ফলাফল প্রিন্ট হবে।


var1[0]:  H
var2[1:5]:  ytho

 

Updating Strings

অন্য একটি স্ট্রিং এর সাথে কোন ভেরিয়েবল এসাইন করে একটি স্ট্রিং কে আপডেট করা যায়। যেমনঃ


#!/usr/bin/python

var1 = 'Hello World!'

print "Updated String :- ", var1[:6] + 'Python'

 

উপরের কোডটি রান করালে নিচের ফলাফল আসবে।


Updated String :- Hello Python

 

Escape Characters

নিচের টেবিলে কিছু Escape Characters দেয়া হল, যেগুলো কখনো প্রোগ্রাম রেসাল্টের প্রিন্টে আসে না। এধরনের Escape Characters ব্যবহার করতে কিছু Backslash notation ব্যবহৃত হয়।

 

Backslash
notation
Hexadecimal
character
Description
\a 0x07 Bell or alert
\b 0x08 Backspace
\cx Control-x
\C-x Control-x
\e 0x1b Escape
\f 0x0c Formfeed
\M-\C-x Meta-Control-x
\n 0x0a Newline
\nnn Octal notation, where n is in the range 0.7
\r 0x0d Carriage return
\s 0x20 Space
\t 0x09 Tab
\v 0x0b Vertical tab
\x Character x
\xnn Hexadecimal notation, where n is in the range 0.9, a.f, or A.F

 

Triple Quotes

Python এ triple quote এর সাহায্যে একাধিক লাইনের স্টেটমেন্ট লেখা হয়। triple quote বোঝাতে তিনটি সিঙ্গেল (’’’) অথবা ডাবল কোটিং (”””) চিহ্ন ব্যবহৃত হয়।


#!/usr/bin/python

para_str = """this is a long string that is made up of
several lines and non-printable characters such as
TAB ( \t ) and they will show up that way when displayed.
NEWLINEs within the string, whether explicitly given like
this within the brackets [ \n ], or just a NEWLINE within
the variable assignment will also show up.
"""
print para_str

 

উপরের কোডটির রেসাল্ট হবে,


this is a long string that is made up of
several lines and non-printable characters such as
TAB (    ) and they will show up that way when displayed.
NEWLINEs within the string, whether explicitly given like
this within the brackets [
 ], or just a NEWLINE within
the variable assignment will also show up.

 

Raw strings ব্যবহার করলে backslash character গুলোর ব্যবহার হয় না। যেমন,


#!/usr/bin/python

print r'C:\\nowhere'

 

উপরের কোডটি চালালে নিচের রেসাল্ট আসবে।


C:\\nowhere


 

Unicode String

Normal strings গুলোকে Python 8-bit ASCII ফরম্যাটে স্টোর করে, কিন্তু Unicode strings গুলো 16-bit Unicode আকারে স্টোর হয়। এর ফলে একটু ভিন্ন ধরনের ক্যারেকটার ব্যবহার করা সম্ভব হয়।


#!/usr/bin/python

print u'Hello, world!'

 

উপরের কোডটি নিচের রেসাল্ট দিবে।


Hello, world!

 

Unicode strings এ prefix u ব্যবহৃত হয়, আর raw strings এ prefix r এর ব্যবহার হয়।

 

Built-in String Methods

Python নিচের বিল্ট−ইন মেথোডগুলোর সাহায্যে স্ট্রিং গুলোকে প্রভাবিত করতে পারে।

SN Methods with Description
1 capitalize()
Capitalizes first letter of string
2 center(width, fillchar)
Returns a space-padded string with the original string centered to a total of width columns.
3 count(str, beg= 0,end=len(string))
Counts how many times str occurs in string or in a substring of string if starting index beg and ending index end are given.
4 decode(encoding=’UTF-8′,errors=’strict’)
Decodes the string using the codec registered for encoding. encoding defaults to the default string encoding.
5 encode(encoding=’UTF-8′,errors=’strict’)
Returns encoded string version of string; on error, default is to raise a ValueError unless errors is given with ‘ignore’ or ‘replace’.
6 endswith(suffix, beg=0, end=len(string))
Determines if string or a substring of string (if starting index beg and ending index end are given) ends with suffix; returns true if so and false otherwise.
7 expandtabs(tabsize=8)
Expands tabs in string to multiple spaces; defaults to 8 spaces per tab if tabsize not provided.
8 find(str, beg=0 end=len(string))
Determine if str occurs in string or in a substring of string if starting index beg and ending index end are given returns index if found and -1 otherwise.
9 index(str, beg=0, end=len(string))
Same as find(), but raises an exception if str not found.
10 isalnum()
Returns true if string has at least 1 character and all characters are alphanumeric and false otherwise.
11 isalpha()
Returns true if string has at least 1 character and all characters are alphabetic and false otherwise.
12 isdigit()
Returns true if string contains only digits and false otherwise.
13 islower()
Returns true if string has at least 1 cased character and all cased characters are in lowercase and false otherwise.
14 isnumeric()
Returns true if a unicode string contains only numeric characters and false otherwise.
15 isspace()
Returns true if string contains only whitespace characters and false otherwise.
16 istitle()
Returns true if string is properly “titlecased” and false otherwise.
17 isupper()
Returns true if string has at least one cased character and all cased characters are in uppercase and false otherwise.
18 join(seq)
Merges (concatenates) the string representations of elements in sequence seq into a string, with separator string.
19 len(string)
Returns the length of the string
20 ljust(width[, fillchar])
Returns a space-padded string with the original string left-justified to a total of width columns.
21 lower()
Converts all uppercase letters in string to lowercase.
22 lstrip()
Removes all leading whitespace in string.
23 maketrans()
Returns a translation table to be used in translate function.
24 max(str)
Returns the max alphabetical character from the string str.
25 min(str)
Returns the min alphabetical character from the string str.
26 replace(old, new [, max])
Replaces all occurrences of old in string with new or at most max occurrences if max given.
27 rfind(str, beg=0,end=len(string))
Same as find(), but search backwards in string.
28 rindex( str, beg=0, end=len(string))
Same as index(), but search backwards in string.
29 rjust(width,[, fillchar])
Returns a space-padded string with the original string right-justified to a total of width columns.
30 rstrip()
Removes all trailing whitespace of string.
31 split(str=””, num=string.count(str))
Splits string according to delimiter str (space if not provided) and returns list of substrings; split into at most num substrings if given.
32 splitlines( num=string.count(‘\n’))
Splits string at all (or num) NEWLINEs and returns a list of each line with NEWLINEs removed.
33 startswith(str, beg=0,end=len(string))
Determines if string or a substring of string (if starting index beg and ending index end are given) starts with substring str; returns true if so and false otherwise.
34 strip([chars])
Performs both lstrip() and rstrip() on string
35 swapcase()
Inverts case for all letters in string.
36 title()
Returns “titlecased” version of string, that is, all words begin with uppercase and the rest are lowercase.
37 translate(table, deletechars=””)
Translates string according to translation table str(256 chars), removing those in the del string.
38 upper()
Converts lowercase letters in string to uppercase.
39 zfill (width)
Returns original string leftpadded with zeros to a total of width characters; intended for numbers, zfill() retains any sign given (less one zero).
40 isdecimal()
Returns true if a unicode string contains only decimal characters and false otherwise.

 

পাইথন প্রোগ্রামিং : নাম্বার (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 ধ্রুবক গুলোর ব্যবহার রয়েছে।

উচ্চ মাধ্যমিক সিলেবাস অনুযায়ী একাদশ-দ্বাদশ শ্রেণীর বইসমূহের পাঠ্যক্রম (কারিকুলাম)

উচ্চ মাধ্যমিক স্তরের শিক্ষাক্রম

সিএসএস৩ বর্ডার ইমেজ (CSS3 Border Images in Bangla)

সিএসএস৩ border-image প্রোপার্টি

সিএসএস৩ border-image প্রোপার্টি দিয়ে একটি এলিমেন্ট এর চারদিকে বর্ডার সেট করতে পারেন।

 

ব্রাউজার সাপর্ট

টেবিলে উল্লেখিত সংখ্যা ব্রাউজার এর প্রথম ভার্সন যা এই প্রোপার্টি সম্পূর্ণভাবে সাপর্ট করে তা বোঝায়।

-webkit- বা -moz- দ্বারা প্রথম প্রিফিক্স ভার্সন বুঝায় যা এই প্রোপার্টি সাপর্ট করে।

Property  Internet Explorer  Google Chrome  Mozila Firefox  Safari  Opera
border-image 11.0 16.0
4.0 -webkit-
15.0
3.5 -moz-
6.0
3.1 -webkit-
15.0
11.0 -o-

 

সিএসএস৩ border-image প্রোপার্টি

সিএসএস৩ border-image প্রোপার্টি যেকোন এলিমেন্ট এর চারিদিকে বর্ডার দিয়ার জন্য ব্যবহার করা হয়।

প্রোপার্টিটি নিম্নোক্ত তিনভাবে অংশগ্রহণ করে:

  1. ইমেজ বর্ডার হিসেবে
  2. ইমেজ এর যেখানে স্লাইস/ভাগ থাকে
  3. মাঝ অংশ যেখানে পুনরাবৃত্তি বা প্রসারিত হবে তা নির্দিষ্ট করে

আমরা নিম্নোক্ত ইমেজটি ব্যবহার করবো (border.png)

বর্ডার

border-image প্রোপার্টি ছবিটিকে নিয়ে একে নয়টি অংশে স্লাইস/ভাগ করে । ইটি চারটি কর্ণারে বসে এবং এবং মধ্যবর্তী অংশ আপনি যেভাবে চান সেই অনুযায়ী – পুনরাবৃত্তি বা প্রসারিত হয়।

নোট: border-image প্রোপার্টি কাজ করার জন্য এলিমেন্টটির বর্ডার প্রোপার্টি সেট প্রয়োজন হবে।

এখানে ইমেজ এর মধ্যবর্তী অংশের পুণরাবৃত্তি ঘটেছে:

Here, the middle sections of the image are repeated to create the border.

এর কোড হচ্ছে


#borderimg {
    border: 10px solid transparent;
    padding: 15px;
    -webkit-border-image: url(border.png) 30 round; /* Safari 3.1-5 */
    -o-border-image: url(border.png) 30 round; /* Opera 11-12.1 */
    border-image: url(border.png) 30 round;
}

 

এখানে মধ্যবর্তী অংশ প্রসারিত হয়েছে:

Here, the middle sections of the image are stretched to create the border.

এর কোড হচ্ছে:


#borderimg {
    border: 10px solid transparent;
    padding: 15px;
    -webkit-border-image: url(border.png) 30 stretch; /* Safari 3.1-5 */
    -o-border-image: url(border.png) 30 stretch; /* Opera 11-12.1 */
    border-image: url(border.png) 30 stretch;
}

 

সিএসএস৩ border-image – বিভিন্ন স্লাইস মান

স্লাইস এর বিভিন্ন মান বর্ডার এর চেহারা পাল্টে দেয়

উদাহরণ 01:

border-image: url(border.png) 50 round;

 

উদাহরণ 02:

border-image: url(‘http://www.w3schools.com/css/border.png’) 20% round;

 

উদাহরণ 03:

border-image: url(border.png) 30% round;

 

এর কোড হচ্ছে:


#borderimg1 {
    border: 10px solid transparent;
    padding: 15px;
    -webkit-border-image: url(border.png) 50 round; /* Safari 3.1-5 */
    -o-border-image: url(border.png) 50 round; /* Opera 11-12.1 */
    border-image: url(border.png) 50 round;
}

#borderimg2 {
    border: 10px solid transparent;
    padding: 15px;
    -webkit-border-image: url(border.png) 20% round; /* Safari 3.1-5 */
    -o-border-image: url(border.png) 20% round; /* Opera 11-12.1 */
    border-image: url(border.png) 20% round;
}

#borderimg3 {
    border: 10px solid transparent;
    padding: 15px;
    -webkit-border-image: url(border.png) 30% round; /* Safari 3.1-5 */
    -o-border-image: url(border.png) 30% round; /* Opera 11-12.1 */
    border-image: url(border.png) 30% round;
}

 

পাইথন প্রোগ্রামিং : লুপ (Python Loops)

1.8 Python Loops

অনেক সময় এমন অবস্থা তৈরি হয় যে একটি নির্দিষ্ট ব্লকের কোড অনেকবার চালানো লাগে, তখন লুপ এর প্রয়োজন হয়। নিচের ছবিটি লক্ষ্য করিঃ

Loop

Python প্রোগ্রামিং ল্যাঙ্গুয়েজে নিচের লুপ গুলো প্রচলিত

.

Loop Type Description
while loop Repeats a statement or group of statements while a given condition is TRUE. It tests the condition before executing the loop body.
for loop Executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.
nested loops You can use one or more loop inside any another while, for or do..while loop.

 

Loop Control Statements

কোডিং এর সময় সাধারণ নিয়মের/ সিরিয়ালের পরিবর্তন বোঝাতে Loop control statements এর প্রয়োজন হয়। যখন একটি নির্দিষ্ট লুপের পরিসীমার বাইরের কোড রান হয় তখন ঐ পরিসীমার সকল অবজেক্ট ধ্বংস হয়ে যায়। Python নিচের কন্ট্রোল স্টেটমেন্ট গুলো সাপোর্ট করে।

 

Control Statement Description
break statement Terminates the loop statement and transfers execution to the statement immediately following the loop.
continue statement Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.
pass statement The pass statement in Python is used when a statement is required syntactically but you do not want any command or code to execute.

 

সিএসএস৩ গোলাকৃতির কর্ণার (CSS3 Rounded Corners in Bangla)

সিএসএস৩ border-radius প্রোপার্টি সাহায্যে আপনি যেকোন এলিমেনন্ট এর “গোলাকৃতির কোর্ণার বা পার্শ্ব” তৈরি করতে পারেন।

ব্রাউজার সাপর্ট

টেবিলে উল্লেখিত সংখ্যা ব্রাউজার এর প্রথম ভার্সন যা এই প্রোপার্টি সম্পূর্ণভাবে সাপর্ট করে তা বোঝায়।

-webkit- বা -moz- দ্বারা প্রথম প্রিফিক্স ভার্সন বুঝায় যা এই প্রোপার্টি সাপর্ট করে।

Property  Internet Explorer Google Crome  Mozila Firefox  Safari Opera
border-radius 9.0 5.0
4.0 -webkit-
4.0
3.0 -moz-
5.0
3.1 -webkit-
10.5

 

সিএসএস৩ border-radius প্রোপার্টি

সিএসএস৩ এ এ border-radius  প্রোপার্টি এর সাহায্যে যেকোন এলিমেন্ট  এর “rounded corners” প্রদান করতে পারেন।

এখানে কিছু উদাহরণ দেয়া হলো:

নির্দিষ্ট ব্যাকগ্রাউন্ড রং বিশিষ্ট একটি এলিমেন্ট এর গোলাকৃতি পার্শ্ব :

Rounded corners!

 

বর্ডার বিশিষ্ট একটি এলিমেন্ট এর গোলাকৃতি পার্শ্ব:

Rounded corners!

 

নির্দিষ্ট ব্যাকগ্রাউন্ড ছবি বিশিষ্ট একটি এলিমেন্ট এর গোলাকৃতি পার্শ্ব :

Rounded corners!

 

এর কোড হচ্ছে:


#rcorners1 {
    border-radius: 25px;
    background: #8AC007;
    padding: 20px;
    width: 200px;
    height: 150px;
}

#rcorners2 {
    border-radius: 25px;
    border: 2px solid #8AC007;
    padding: 20px;
    width: 200px;
    height: 150px;
}

#rcorners3 {
    border-radius: 25px;
    background: url(paper.gif);
    background-position: left top;
    background-repeat: repeat;
    padding: 20px;
    width: 200px;
    height: 150px;
}

 

টিপস: border-radius হচ্ছে border-top-left-radius, border-top-right-radius, border-bottom-right-radius এবং border-bottom-left-radius এর সংক্ষিপ্ত প্রোপার্টি।

 

সিএসএস৩ border-radius প্রতিটি আলাদা পার্শ্ব পরিবর্তন

যদি আপনি border-radius প্রোপার্টি এর একটিমাত্র মান নির্ধারণ করেন তাহলে তা চারটি কর্ণারের উপরই কার্যকর হবে।

যদি আপনি চান তাহলে প্রতিটি আলাদা পার্শ্ব এর মান নির্ধারণ করে দিতে পারেন। এখানে তার নিয়ম দেয়া হলো:

  • চারটি মান: প্রথম মান উপরের বাম পাশের, দ্বিতীয় মান উপরের ডান পাশের, তৃতীয় মান নিচের ডান পাশের এবং চতুর্থ মান নিচের বাম পাশের কর্ণারের উপর প্রয়োগ হয়।
  • তিনটি মান: প্রথম মান উপরের বাম পাশে, দ্বিতীয় মান উপরের ডান পাশ ও নিচের বাম পাশে এবং তৃতীয় মান নিচের ডান পাশের কর্ণারের উপর কাজ করে।
  • দুইটি মান: প্রথম মান উপরের বাম পাশ ও নিচের ডান পাশ এবং দ্বিতীয় মান উপরের ডান পাশ ও নিচের বাম পাশের কর্ণারের উপর কাজ করে।
  • একটি মান: চারটি কর্ণরকেই সমানভাবে গোলাকৃতি করে।

 

এখানে তিনটি উদাহরণ দেয়া হলো:

১. চারটি মান – border-radius: 15px 50px 30px 5px:

Rounded corners!

২. তিনটি মান – border-radius: 15px 50px 30px:

Rounded corners!

৩. দুইটি মান – border-radius: 15px 50px:

Rounded corners!

 

এখানে এর কোড দেয়া হলো:


#rcorners4 {
    border-radius: 15px 50px 30px 5px;
    background: #8AC007;
    padding: 20px;
    width: 200px;
    height: 150px;
}

#rcorners5 {
    border-radius: 15px 50px 30px;
    background: #8AC007;
    padding: 20px;
    width: 200px;
    height: 150px;
}

#rcorners6 {
    border-radius: 15px 50px;
    background: #8AC007;
    padding: 20px;
    width: 200px;
    height: 150px;
}

 

আপনি উপবৃত্তাকার কোণও তৈরি করতে পারেন:


#rcorners7 {
    border-radius: 50px/15px;
    background: #8AC007;
    padding: 20px;
    width: 200px;
    height: 150px;
}

#rcorners8 {
    border-radius: 15px/50px;
    background: #8AC007;
    padding: 20px;
    width: 200px;
    height: 150px;
}

#rcorners9 {
    border-radius: 50%;
    background: #8AC007;
    padding: 20px;
    width: 200px;
    height: 150px;
}

পাইথন প্রোগ্রামিং : সিদ্ধান্ত গ্রহণ (Python Decision Making)

1.7 Python Decision Making

Decision Making অর্থাৎ সিদ্ধান্ত নেয়াটা যেকোনো প্রোগ্রামিং ল্যাঙ্গুয়েজ এর একটি প্রচলিত অংশ, যেখানে প্রোগ্রামটি কিছু প্রদত্ত শর্তের উপর ভিত্তিতে কোন একটি প্রোসেস সত্য নাকি মিথ্যা সেটা যাচাই করে। প্রায় সব প্রোগ্রামিং ল্যাংগুয়েজেই Decision Making এর ব্যাপার আছে। নিচের চিত্রে Decision Making এর একটা ব্যাসিক ধারণা দেয়া হলঃ

Decision Making

কোন শর্ত যদি মিথ্যা হয়, তবে Python সেটার ফলাফল ধরে শূন্য (=০), আর যদি সত্য হয় তবে সেক্ষেত্রে ০ ছাড়া যেকোনো মান (সাধারণত = ১)। নিচে Python এ ব্যবহৃত Decision Making টাইপ গুলো বলা হলঃ

if statements

if statement এ অন্যান্য প্রোগ্রামিং ল্যাংগুয়েজের মতই একটি শর্ত থাকে যার সাহায্যে একাধিক ডাটার তুলনা করা হয়, এবং সিদ্ধান্ত নেয়া হয়। এই স্টেটমেন্টটি boolean expression অনুসরন করে (অর্থাৎ শর্তটি সত্য নাকি মিথ্যা সেটা যাচাই করে) শুধুমাত্র ২ ধরনের ফলাফল দিতে পারে।

Syntax


if expression:
   statement(s)

 

যদি If এর পরে ব্যবহৃত boolean expression টি TRUE হয়, তবে পরবর্তী statement(s) টি ঘটবে, আর যদি FALSE হয়, তবে if statement(s) টি শেষ হবে এবং এর পরের প্রথম code টি ঘটবে।

উদাহরণ


#!/usr/bin/python

var1 = 100
if var1:
   print "1 - Got a true expression value"
   print var1

var2 = 0
if var2:
   print "2 - Got a true expression value"
   print var2
print "Good bye!"

 

উপরের প্রোগ্রামটি রান করালে নিচের ফলাফল প্রিন্ট হবে।


1 - Got a true expression value
100
Good bye!

 

আবার, if statement এর পরে এক লাইনের শর্ত (স্টেটমেন্ট) থাকলে সেটি if statement এর পরেই একই লাইনে লেখা যেতে পারে। যেমন,


#!/usr/bin/python

var = 100

if ( var  == 100 ) : print "Value of expression is 100"

print "Good bye!"

 

উপরের প্রোগ্রামটি রান করালে নিচের ফলাফল প্রিন্ট হবে।


Value of expression is 100
Good bye!

 

if…else statements

এক্ষেত্রে if statement এর পরেই একটি else statement ও থাকে, যার ফলে যদি প্রথম if statement টি মিথ্যা হয় (মান=০) তবে পরবর্তী else statement এর কোডটি ঘটবে।

Syntax


if expression:
   statement(s)
else:
   statement(s)

 

উদাহরণ


#!/usr/bin/python

var1 = 100
if var1:
   print "1 - Got a true expression value"
   print var1
else:
   print "1 - Got a false expression value"
   print var1

var2 = 0
if var2:
   print "2 - Got a true expression value"
   print var2
else:
   print "2 - Got a false expression value"
   print var2

print "Good bye!"

 

উপরের প্রোগ্রামটি রান করালে নিচের ফলাফল প্রিন্ট হবে।


1 - Got a true expression value
100
2 - Got a false expression value
0
Good bye!

 

elif Statement

elif statement এর সাহায্যে একটি if statement এর পরে একসঙ্গে একাধিক এক্সপ্রেশন (elif statement) যাচাই করে দেখা যায় কোনটা সত্য, তারপর যেই স্টেটমেন্টটি সত্য (TRUE) সেটার কোড চালু হয়। else এর মত elif statement ও optional.

syntax


if expression1:
   statement(s)
elif expression2:
   statement(s)
elif expression3:
   statement(s)
else:
   statement(s)

 

Python এ switch কিংবা case statements নেই, তবে switch করার দরকার পরলে if..elif…statements দিয়ে কাজ চালানো যায়।

উদাহরণ


#!/usr/bin/python

var = 100
if var == 200:
   print "1 - Got a true expression value"
   print var
elif var == 150:
   print "2 - Got a true expression value"
   print var
elif var == 100:
   print "3 - Got a true expression value"
   print var
else:
   print "4 - Got a false expression value"
   print var

print "Good bye!"

 

উপরের প্রোগ্রামটি রান করালে নিচের ফলাফল প্রিন্ট হবে।


3 – Got a true expression value
100
Good bye!


nested if statements

একটি শর্ত পূরন হবার পরে আরেকটি ভিন্ন শর্ত পূরন হয়েছে কিনা সেটা দেখতে nested if  স্টেটমেন্ট ব্যবহার হয়। এই ধরনের Decision making অপেক্ষাকৃত জটিল, এবং এখানে একটি  if… elif… else এর অংশ হতে পারে।

Syntax:


if expression1:
   statement(s)
   if expression2:
      statement(s)
   elif expression3:
      statement(s)
   else
      statement(s)
elif expression4:
   statement(s)
else:
   statement(s)

 

উদাহরন:


#!/usr/bin/python

var = 100
if var < 200:
   print "Expression value is less than 200"
   if var == 150:
      print "Which is 150"
   elif var == 100:
      print "Which is 100"
   elif var == 50:
      print "Which is 50"
elif var < 50:
   print "Expression value is less than 50"
else:
   print "Could not find true expression"

print "Good bye!"

 

উপরের প্রোগ্রামটি রান করালে নিচের ফলাফল প্রিন্ট হবে।


Expression value is less than 200
Which is 100
Good bye!

 

পাইথন প্রোগ্রামিং : মৌলিক অপারেটরসমূহ (Python Basic Operators in Bangla)

1.6 Python Basic Operators

একটি সহজ সমীকরণ বিবেচনা করিঃ ৪ + ৫ = ৯; এখানে ৪ এবং ৫ সংখ্যাগুলোকে হচ্ছে ‘operands’ এবং ‘+’ হচ্ছে ‘operators’। Python এ নিম্নোক্ত operators গুলো ব্যবহৃত হয়।

  • Arithmetic Operators
  • Comparison (Relational) Operators
  • Assignment Operators
  • Logical Operators
  • Bitwise Operators
  • Membership Operators
  • Identity Operators

নিচে কিছু উদাহরণ দেয়া হয়েছে (এখানে, a = 10 এবং b = 20)।

Operator Description Example

Python Arithmetic Operators (যোগ, বিয়োগ, গুন, ভাগ ইত্যাদি)

+ যোগ Operator এর দুইপাশের মান গুলো যোগ করে। a + b = 30
– বিয়োগ Operator এর বাম পাশের মান থেকে ডান পাশের মান বিয়োগ করে। a – b = -10
* গুন Operator এর দুইপাশের মান গুলো গুন করে। a * b = 200
/ ভাগ Operator এর বাম পাশের মানকে ডান পাশের মান দিয়ে ভাগ করে। b / a = 2
% Modulus (ভাগশেষ) Operator এর বাম পাশের মানকে ডান পাশের মান দিয়ে ভাগ করে ভাগশেষ নির্নয় করে। b % a = 0
** Exponent (পাওয়ার) Operators এর পাওয়ার নির্নয় করে। a**b =1020
// Floor Division (পূর্ণ-সংখ্যার ভাগফল) Operator এর বাম পাশের মানকে ডান পাশের মান দিয়ে ভাগ করে ভাগফল বের করে এবং দশমিকের আগ পর্যন্ত (পূর্ণ-সংখ্যা) মান নির্নয় করে। 9//2 = 4 এবং 9.0//2.0 = 4.0

Python Comparison Operators (দুটি operand এর তুলনা ও সম্পর্ক স্থাপন)।

== সমান চিহ্ন। (a == b) সঠিক নয়।
!= অথবা <> অসমান চিহ্ন। (a != b) সঠিক।
>, <, >= এবং <= অসমতা’র চিহ্ন। (a > b) সঠিক নয়, আবার (a <= b) সঠিক।

Python Assignment Operators

= ডান দিকের operand এর মান বাম পাশের operand এ রেকর্ড করে। c = a + b অর্থ a + b এর মান c তে রেকর্ড করা
+= Add AND ডান দিকের operand এর মান বাম পাশের operand এর সাথে যোগ করে নতুন করে বাম দিকের operand এর মান হিসেবে রেকর্ড করে। c += a এর অর্থ c = c + a
-= Subtract AND ডান দিকের operand এর মান বাম পাশের operand থেকে বিয়োগ করে নতুন করে বাম দিকের operand এর মান হিসেবে রেকর্ড করে। c -= a এর অর্থ c = c – a
*= Multiply AND দুই পাশের operand গুন করে বাম দিকের operand এর নতুন মান হিসেবে রেকর্ড করে। c *= a এর অর্থ c = c * a
/= Divide AND বাম দিকের operand ডান পাশের operand দিয়ে ভাগ করে প্রাপ্ত ভাগফল বাম দিকের operand এর নতুন মান হিসেবে রেকর্ড করে। c /= a এর অর্থ c = c / a
%= Modulus AND দুই দিকের operands এর মডুলাস (ভাগশেষ) বাম পাশের operand এর মান হিসেবে রেকর্ড করে। c %= a এর অর্থ c = c % a
**= Exponent AND দুই দিকের operands এর পাওয়ার বাম পাশের operand এর মান হিসেবে রেকর্ড করে। c **= a এর অর্থ c = ca
//= Floor Division দুই দিকের operands এর Floor Division বাম পাশের operand এর মান হিসেবে রেকর্ড করে। c //= a এর অর্থ c = c // a

Python Bitwise Operators (বাইনারি হিসাব)

মনে a = 60; এবং b = 13 হয়, তবে বাইনারি ফরম্যাট এ a = 0011 1100 এবং b = 0000 1101
a&b = 0000 1100

a|b = 0011 1101

a^b = 0011 0001

~a  = 1100 0011

Python Membership Operators

in অথবা not in একটি ভেরিয়েবল একটি বিশেষ সিরিজ অথবা ধারার অংশ হিসেবে যথাক্রমে থাকা বা না থাকা নির্দেশ করে। x in y এর ফলাফল 1 হবে যদি x ভেরিয়েবলটি y ধারার অংশ হয়, তেমনই ভাবে x not in y এর মান 1 হবে যদি x ভেরিয়েবলটি y ধারার অংশ না হয়।

Python Identity Operators

is এই অপারেটর বুঝায় যে এর দুই পাশের ভেরিয়েবলগুলো একই বস্তু নির্দেশ করে। x is y এর ফলাফল 1 হবে যদি x ও y একই বস্তু বোঝায়।
is not এই অপারেটর বুঝায় যে এর দুই পাশের ভেরিয়েবলগুলো একই বস্তু নির্দেশ করে না। x is not y এর ফলাফল 1 হবে যদি x ও y একই বস্তু না বোঝায়।

Python Operators Precedence (অগ্রাধিকার)

নিচে Python এর অপারেটর এর সিরিয়াল/ অগ্রাধিকার (কোনটির কাজ আগে হবে) দেয়া হলঃ

  1. **
  2. ~ + –
  3. * / % //
  4. + –
  5. >> <<
  6. &
  7. ^ |
  8. <= < > >=
  9. <> == !=
  10. = %= /= //= -= += *= **=
  11. is is not
  12. in not in
  13. not or and

পাইথন প্রোগ্রামিং : ভেরিয়েবল টাইপ (Python Variable Types in bangla)

1.5 Python Variable Types

ভেরিয়েবল হচ্ছে মেমোরি তে নির্ধারিত জায়গা (স্পেস) যেখানে বিভিন্ন জিনিসের মান (value) স্টোর করে রাখা হয়। ভেরিয়েবল তৈরি করা মানেই কম্পিউটারের মেমোরিতে একটা নির্দৃষ্ট স্পেস সঞ্চয় করে রাখা। যেকোনো ভেরিয়েবল কি ধরনের ডাটা রেকর্ড/ স্টোর করবে সেটা নির্ভর করে ভেরিয়েবল উপর।

Python এ সমতা চিহ্নের (=) মাধ্যমে যেকোনো ধরনের মান (value) ভেরিয়েবল হিসেবে স্টোর করা যায়, এক্ষেত্রে আলাদা করে কোন ডিক্লারেশনের প্রয়োজন নেই। সমতা চিহ্নের বাম পাশে ব্যবহৃত শব্দটি ভেরিয়েবলের নাম এবং ডান পাশের সংখ্যাটি ভেরিয়েবলের মান নির্দেশ করে। যেমন,


#!/usr/bin/python

counter = 100          # An integer assignment
miles   = 1000.0       # A floating point
name    = "John"       # A string

print counter
print miles
print name

উপরের প্রোগ্রামটির ফলাফল হবে এমন,


1001000.0


 

Python এ একাধিক ভেরিয়েবলের জন্য একটি নির্দৃষ্ট মান স্টোর করা যায়। আবার একাধিক ভেরিয়েবলের জন্য যথাক্রমে একাধিক মানও একসাথে স্টোর করা যায়। যেমন,


a = b = c = 1


 

এবং


a, b, c = 1, 2, “john”


 

প্রথম প্রোগ্রামটিতে a, b এবং c এর মান 1 স্টোর করা হয়েছে, আর দ্বিতীয় প্রোগ্রামটিতে a, b এবং c এর মান যথাক্রমে 1, 2 এবং john স্টোর করা হয়েছে।

Python এ ৫ ধরনের স্ট্যান্ডার্ড ডাটা টাইপ আছে। যেমন,

  • Numbers
  • String
  • List
  • Tuple
  • Dictionary

Numbers

Numbers হচ্ছে যেকোনো প্রকারের সংখ্যা। Python ৪ ধরনের সংখ্যা (Numbers) সাপোর্ট করে। যেমন,

  • int (ছোট পূর্ণসংখ্যা)
  • long (বড় পূর্ণসংখ্যা, octal কিংবা hexadecimal আকারে প্রকাশ করা যায়)
  • float (বাস্তব সংখ্যার কাছাকাছি মান)
  • complex (জটিল সংখ্যা)

নিচের টেবিলে কিছু সংখ্যার উদাহরণ দেয়া হলঃ

int long float complex
10 51924361L 0.0 3.14j
080 0xDEFABCECBDAECBFBAEl 32.3+e18 .876j
-0490 535633629843L -90. -.6545+0J

 

Strings

Strings হচ্ছে কোটেশান মার্কের (“”) ভেতর ব্যবহৃত বর্ণ/ শব্দ সমূহ। বিভিন্ন রকমের slice operator ([ ] and [:]) এর সাহায্য নিয়ে নির্ধারিত string এর অংশবিশেষ অথবা বিভিন্ন পূনর্বিন্যাস আউটপুট হিসেবে দেখা যায়। যেমন,


#!/usr/bin/python

str = 'Hello World!'

print str          # Prints complete string
print str[0]       # Prints first character of the string
print str[2:5]     # Prints characters starting from 3rd to 5th
print str[2:]      # Prints string starting from 3rd character
print str * 2      # Prints string two times
print str + "TEST" # Prints concatenated string

 

উপরের প্রোগ্রামটির ফলাফল হবে,


Hello World!
H
llo
llo World!
Hello World!Hello World!
Hello World!TEST

 

Lists

List হল তৃতীয় ব্র্যাকেট ([ ]) এ আবদ্ধ, ও কমা (commas) দিয়ে আলাদা করা আইটেম। যেমন,


#!/usr/bin/python

list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
tinylist = [123, 'john']

print list          # Prints complete list
print list[0]       # Prints first element of the list
print list[1:3]     # Prints elements starting from 2nd till 3rd 
print list[2:]      # Prints elements starting from 3rd element
print tinylist * 2  # Prints list two times
print list + tinylist # Prints concatenated lists

 

উপরের প্রোগ্রামটির রেসাল্ট হবে,


['abcd', 786, 2.23, 'john', 70.200000000000003]
abcd
[786, 2.23]
[2.23, 'john', 70.200000000000003]
[123, 'john', 123, 'john']
['abcd', 786, 2.23, 'john', 70.200000000000003, 123, 'john']

 

Tuples

Tuple আর List মূলত একই রকম, শুধু পার্থক্য হচ্ছে যে Tuple এ প্রথম ব্র্যাকেট ( ) ব্যবহৃত হয়, কিন্তু List এ তৃতীয় ব্র্যাকেট [ ] ব্যবহার হয়। এছাড়াও Tuple এর মান পরে পরিবর্তন করা যায়না (read-only values), কিন্তু List এর মান আপডেট করা যায়। Tuple এর উদাহরনঃ


#!/usr/bin/python

tuple = ( 'abcd', 786 , 2.23, 'john', 70.2  )
tinytuple = (123, 'john')

print tuple           # Prints complete list
print tuple[0]        # Prints first element of the list
print tuple[1:3]      # Prints elements starting from 2nd till 3rd 
print tuple[2:]       # Prints elements starting from 3rd element
print tinytuple * 2   # Prints list two times
print tuple + tinytuple # Prints concatenated lists

 

উপরের প্রোগ্রামের ফলাফলঃ


('abcd', 786, 2.23, 'john', 70.200000000000003)
abcd
(786, 2.23)
(2.23, 'john', 70.200000000000003)
(123, 'john', 123, 'john')
('abcd', 786, 2.23, 'john', 70.200000000000003, 123, 'john')

 

নিচের Tuple কোডটি ভুল, কারন এখানে Tuple এর মান পরিবর্তন/ আপডেট করার চেষ্টা করা হয়েছে। কিন্তু List এর জন্য কোডটি ঠিক আছে।


#!/usr/bin/python

tuple = ( 'abcd', 786 , 2.23, 'john', 70.2  )
list = [ 'abcd', 786 , 2.23, 'john', 70.2  ]
tuple[2] = 1000    # Invalid syntax with tuple
list[2] = 1000     # Valid syntax with list

 

Dictionary

Dictionary দিয়ে Key-Value জোড়ায় জোড়ায় থাকে। যেকোনো ডাটা টাইপ Key হতে পারে, যদিও সাধারণত numbers বা strings ই Key হিসেবে রেকর্ডেড হয়। অন্যদিকে, যেকোনো সংখ্যা/ অবজেক্টই Value হিসেবে রেকর্ড হতে পারে। Dictionary দ্বিতীয় ব্র্যাকেট { } এর সাহায্যে প্রকাশ করা হয় এবং তৃতীয় ব্র্যাকেটের সাহাজে Doctionary তে Value এসাইন করা হয়। যেমন,


#!/usr/bin/python

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

 

উপরের কোড এর রেসাল্ট হবে −


This is one
This is two
{‘dept’: ‘sales’, ‘code’: 6734, ‘name’: ‘john’}
[‘dept’, ‘code’, ‘name’]
[‘sales’, 6734, ‘john’]


এখানে উল্লেখ্য যে, Dictionary তে ক্রম, সিরিয়াল বা অর্ডার ঠিক রাখার কোন ব্যপার নেই।

 

Data Type Conversion

Python এ একধরনের ডাটা টাইপ থেকে আরেকটিতে রূপান্তর করার জন্য কিছু বিল্ট-ইন ফাংশন আছে, যেগুলো আউটপুট হিসেবে পরিবর্তিত মান সহ নতুন অবজেক্ট তৈরি করে। নিচে কিছু ফাংশন ও তাদের অর্থ দেয়া হলঃ

ফাংশন বর্ননা
int(x [,base]) x কে একটি পূর্ণসংখ্যায় রূপান্তর করে, এবং base লিখাটি বেস কে নির্দেশ (specify) করে যদি x একটি স্ট্রিং হয়।
long(x [,base] ) x কে একটি দীর্ঘ পূর্ণসংখ্যায় রূপান্তর করে, এবং base লিখাটি বেস কে নির্দেশ (specify) করে যদি x একটি স্ট্রিং হয়।
float(x) x কে একটি floating-point সংখ্যায় রূপান্তর করে।
complex(real [,imag]) জটিল সংখ্যা তৈরি করে।
str(x) x কে একটি string representation এ রূপান্তর করে।
repr(x) x কে একটি expression string এ রূপান্তর করে।
eval(str) একটি string কে এভালুয়েট করে এবং একটি নতুন অবজেক্ট সৃষ্টি করে।
tuple(s) s কে একটি tuple এ রূপান্তর করে।
list(s) s কে list এ রূপান্তর করে।
set(s) s কে set এ রূপান্তর করে।
dict(d) একটি dictionary তৈরি করে। তবে, d কে অবশ্যই (key,value) ফরম্যাট এর tuples হতে হবে.
frozenset(s) s কে frozen set এ রূপান্তর করে।
chr(x) একটি integer কে একটি character এ রূপান্তর করে।
unichr(x) একটি integer কে একটি Unicode character এ রূপান্তর করে।
ord(x) একটি single character কে এর পূর্ণ-সাঙ্খ্যিক (integar) মানে প্রকাশ করে।
hex(x) একটি integer কে একটি hexadecimal string এ রূপান্তর করে।
oct(x) একটি integer কে একটি octal string এ রূপান্তর করে।