• পাইথন কোড উদাহরণ

    পাইথন একটি সাধারণ উদ্দেশ্য প্রোগ্রামিং ভাষা, যা dynamically typed, interpreted/গতিময়ভাবে টাইপ করা, ব্যাখ্যা করা এবং great design principles গুলির সাথে সহজ পাঠযোগ্যতার জন্য পরিচিত

    ফ্রিকোডক্যাম্পে পাইথনের সর্বাধিক জনপ্রিয় কোর্স রয়েছে। এটি সম্পূর্ণ বিনামূল্যে (এবং এমনকি কোনও বিজ্ঞাপনও নেই)  আপনি এটি এখানে ইউটিউবে দেখতে পারেন।

    https://www.youtube.com/watch?v=rfscVS0vtbw

    পাইথন ডেটা স্ট্রাকচার উদাহরণ
    floating point numbers এবং পাইথনে তারা কীভাবে কাজ করে সে সম্পর্কে কিছু সাধারণ তথ্য এখানে পাওয়া যাবে।

    পাইথনের প্রায় সমস্ত বাস্তবায়ন IEEE 754 স্পেসিফিকেশন অনুসরণ করে: বাইনারি ফ্লোটিং-পয়েন্ট অ্যারিমেটিকের জন্য স্ট্যান্ডার্ড। IEEE site.সাইটে আরও তথ্য পাওয়া যায়।
    Float objects can be created using floating point literals:

    >>> 3.14
    3.14
    >>> 314\.    # Trailing zero(s) not required.
    314.0
    >>> .314    # Leading zero(s) not required.
    0.314
    >>> 3e0
    3.0
    >>> 3E0     # 'e' or 'E' can be used.
    3.0
    >>> 3e1     # e ই এর পরে Positive value দশমিককে ডানে সরিয়ে দেয়
    30.0
    >>> 3e-1    # Negative value after e moves the decimal to the left.ই এর পরে নেতিবাচক মান দশমিককে বাম দিকে সরায়।
    0.3
    >>> 3.14e+2 #'+' প্রয়োজন হয় না তবে এক্সপোনেন্ট অংশের জন্য ব্যবহার করা যায়। '+' not required but can be used for exponent part.
    314.0
    সংখ্যাসূচক অক্ষরে কোনও চিহ্ন থাকে না, তবে নেটিরিয়াল - (বিয়োগ) অপারেটরের সাথে আক্ষরিকের আগে কোনও স্থান না থাকায় প্রাকটিক্স করে নেতিবাচক ফ্লোট অবজেক্ট তৈরি করা সম্ভব:

    >>> -3.141592653589793
    -3.141592653589793
    >>> type(-3.141592653589793)
    <class 'float'>
    তেমনি,  Positive ফ্লোট অবজেক্টগুলিকে আক্ষরিকের আগে কোনও স্থান ছাড়াই একটি unary + (প্লাস) অপারেটরের সাথে উপসর্গ করা যেতে পারে। সাধারণত + বাদ দেওয়া হয়:

    >>> +3.141592653589793
    3.141592653589793
    Note that leading and trailing zero(s) are valid for floating point literals.
    মনে রাখবেন যে
    শীর্ষস্থানীয় এবং অনুগামী শূন্য (গুলি) ভাসমান পয়েন্ট আক্ষরিক জন্য বৈধ।
    >>> 0.0
    0.0
    >>> 00.00
    0.0
    >>> 00100.00100
    100.001
    >>> 001e0010      # Same as 1e10
    10000000000.0
    ফ্লোট কনস্ট্রাক্টর ফ্লোট অবজেক্ট তৈরির অন্য উপায় 

     floating point literals সহ ভাসমান অবজেক্ট তৈরি করা যখন সম্ভব হয়:

    >>> a = 3.14         # Prefer floating point literal when possible.
    >>> type(a)
    <class 'float'>
    >>> b = int(3.14)    # Works but unnecessary.
    >>> type(b)

    <class 'float'>


    যাইহোক, ভাসা নির্মাতা অন্যান্য সংখ্যা প্রকার থেকে ভাসমান অবজেক্ট তৈরি করার অনুমতি দেয়:

    >>> a = 4
    >>> type(a)
    <class 'int'>
    >>> print(a)
    4
    >>> b = float(4)
    >>> type(b)
    <class 'float'>
    >>> print(b)
    4.0
    >>> float(400000000000000000000000000000000)
    4e+32
    >>> float(.00000000000000000000000000000004)
    4e-32
    >>> float(True)
    1.0
    >>> float(False)
    0.0
    The float constructor 
    0.0


    float constructor স্ট্রিংগুলি থেকে number literals-র প্রতিনিধিত্ব করে float objects তৈরি করবে:

    >>> float('1')
    1.0
    >>> float('.1')
    0.1
    >>> float('3.')
    3.0
    >>> float('1e-3')
    0.001
    >>> float('3.14')
    3.14
    >>> float('-.15e-2')
    -0.0015

    ফ্লোট কনস্ট্রাক্টরটি NaN (Not a Number), negative infinity and infinity সংখ্যা উপস্থাপনা করতেও ব্যবহার করা যেতে পারে (নোট করুন যে এর জন্য স্ট্রিংগুলি সংবেদনশীল নয়):

    >>> float('nan')
    nan
    >>> float('inf')
    inf
    >>> float('-inf')
    -inf
    >>> float('infinity')
    inf
    >>> float('-infinity')
    -inf

    পাইথন বুলের উদাহরণ/Python Bools Example
    bool() পাইথন 3-এ একটি  built-in function  এই ফাংশনটি বুলিয়ান মান দেয়, অর্থাত সত্য বা মিথ্যা। এটি একটি argument/যুক্তি লাগে, x।

    যুক্তি/argument
    এটি একটি যুক্তি/argument লাগে, x.। স্ট্যান্ডার্ড ট্রুথ টেস্টিং পদ্ধতি ব্যবহার করে x রূপান্তরিত।

    ফেরত মূল্য/Return Value
    যদি x false or omitted দেওয়া হয় তবে এটি মিথ্যা ফিরিয়ে দেয়; অন্যথায় এটি True/সত্য ফিরে আসে।

    কোড নমুনা/Code Sample

    print(bool(4 > 2)) # Returns True as 4 is greater than 2
    print(bool(4 < 2)) # Returns False as 4 is not less than 2
    print(bool(4 == 4)) # Returns True as 4 is equal to 4
    print(bool(4 != 4)) # Returns False as 4 is equal to 4 so inequality doesn't holds
    print(bool(4)) # Returns True as 4 is a non-zero value
    print(bool(-4)) # Returns True as -4 is a non-zero value
    print(bool(0)) # Returns False as it is a zero value
    print(bool('dskl')) # Returns True as the string is a non-zero value
    print(bool([1, 2, 3])) # Returns True as the list is a non-zero value
    print(bool((2,3,4))) # Returns True as tuple is a non-zero value
    print(bool([])) # Returns False as list is empty and equal to 0 according to truth value testing

    Python Bool Operators Example
    and, or, not

    Python Docs - Boolean Operationsপাইথন ডক্স - বুলিয়ান অপারেশনস

    These are the Boolean operations, ordered by ascending priority:

    Operation Result Notes x or y if x is false, then y, else x (1) x and y if x is false, then x, else y (2) not x if x is false, then True, else False (3).

    অপারেশন রেজাল্ট নোটস x বা y যদি x মিথ্যা হয় তবে y, অন্য x (1) xand y যদি x মিথ্যা হয়, তবে x, অন্য y (2) x না হলে x মিথ্যা, তবে সত্য, অন্যথায় মিথ্যা (3)।

    Notes:

    This is a short-circuit operator, so it only evaluates the second argument if the first one is False.
    This is a short-circuit operator, so it only evaluates the second argument if the first one is True.
    not has a lower priority than non-Boolean operators, so not a == b is interpreted as not (a == b), and a == not b is a syntax error.
    এটি একটি শর্ট সার্কিট অপারেটর, সুতরাং এটি প্রথম যুক্তিটি মিথ্যা হলে কেবলমাত্র দ্বিতীয় যুক্তির মূল্যায়ন করে।
    এটি একটি শর্ট সার্কিট অপারেটর, সুতরাং এটি যদি প্রথম যুক্তিটি সত্য হয় তবে এটি কেবল দ্বিতীয় যুক্তির মূল্যায়ন করে।

    নন-বুলিয়ান অপারেটরগুলির চেয়ে কম অগ্রাধিকার নেই, সুতরাং a == b কে (a == b) না হিসাবে ব্যাখ্যা করা হয়, এবং a == b নয় একটি syntax error।

    Examples:

    not:
    >>> not True
    False
    >>> not False
    True

    and:
    >>> True and False    # প্রথম যুক্তিতে শর্ট সার্কিট।Short-circuited at first argument.
    False
    >>> False and True    # দ্বিতীয় যুক্তির মূল্যায়ন করা হয়Second argument is evaluated.
    False
    >>> True and True     # দ্বিতীয় যুক্তির মূল্যায়ন করা হয়Second argument is evaluated.
    True

    or:
    >>> True or False    # প্রথম যুক্তিতে শর্ট সার্কিট Short-circuited at first argument.
    True
    >>> False or True    #দ্বিতীয় যুক্তির মূল্যায়ন করা হয় Second argument is evaluated.
    True
    >>> False or False   # দ্বিতীয় যুক্তির মূল্যায়ন করা হয়Second argument is evaluated.
    False
    Python

    Python Constant Example
    Three commonly used built-in constants:

    True: The true value of the bool type. Assignments to True raise a SyntaxError.

    False: The false value of the bool type. Assignments to False raise a SyntaxError.

    None : The sole value of the type NoneType. None is frequently used to represent the absence of a value, as when default arguments are not passed to a function. Assignments to None raise a SyntaxError.


    Other built-in constants:

    Not Implemented: Special value which should be returned by the binary special methods, such as __eg__(), __add__(), __rsub__(), etc.) to indicate that the operation is not implemented with respect to the other type.

    Ellipsis: Special value used mostly in conjunction with extended slicing syntax for user-defined container data types.
    __debug__: True if Python was not started with an -o option.

    Constants added by the site module. The site module (which is imported automatically during startup, except if the -S command-line option is given) adds several constants to the built-in namespace. They are useful for the interactive interpreter shell and should not be used in programs.
    সাইট মডিউল দ্বারা ধ্রুবক যুক্ত। সাইট মডিউল (যা প্রারম্ভকালে স্বয়ংক্রিয়ভাবে আমদানি করা হয়, -S কমান্ড-লাইন বিকল্পটি দেওয়া ব্যতীত) অন্তর্নির্মিত নেমস্পেসে বেশ কয়েকটি ধ্রুবক যুক্ত করে। এগুলি ইন্টারেক্টিভ ইন্টারপ্রেটার শেলের জন্য কার্যকর এবং প্রোগ্রামগুলিতে ব্যবহার করা উচিত নয়।

    Objects that, when printed, print a message like “Use quit() or Ctrl-D (i.e. EOF) to exit”, and when called, raise SystemExit with the specified exit code:
    যে বিষয়গুলি মুদ্রিত করা হয়, "প্রস্থান করার জন্য ব্যবহার ছেড়ে দিন") বা Ctrl-D (অর্থাত্ EOF) এর মতো একটি বার্তা মুদ্রণ করে এবং যখন ডাকা হয় তখন নির্দিষ্ট প্রস্থান কোডের সাহায্যে SystemExit উত্থাপন করে:

    quit(code=None)
    exit(code=None)
    Objects that, when printed, print a message like “Type license() to see the full license text”, and when called, display the corresponding text in a pager-like fashion (one screen at a time):
    যে বিষয়গুলি মুদ্রিত করা হয়, "সম্পূর্ণ লাইসেন্সের পাঠ্যটি দেখতে" টাইপ লাইসেন্স () এর মতো একটি বার্তা মুদ্রণ করে, এবং যখন ডাকা হয়, তখন পেজারের মতো ফ্যাশনে (একই সাথে একটি স্ক্রিন) প্রাসঙ্গিক প্রদর্শিত হয়:

    copyright
    license
    credits
    Calling Python Function Example
    A function definition statement does not execute the function. Executing (calling) a function is done by using the name of the function followed by parenthesis enclosing required arguments (if any).

    কপিরাইট,লাইসেন্স,ক্রেডিট
    পাইথন ফাংশন উদাহরণ কল করা
    একটি ফাংশন সংজ্ঞা বিবৃতি ফাংশন কার্যকর করে না। এক্সিকিউটিং (কলিং) ফাংশনটির নামটি ব্যবহার করে অনুসরণ করা হয় যার পরে বন্ধনী আবদ্ধ প্রয়োজনীয় আর্গুমেন্টগুলি (যদি থাকে)।

    >>> def say_hello():
    ...     print('Hello')
    ...
    >>> say_hello()
    Hello


    The execution of a function introduces a new symbol table used for the local variables of the function. More precisely, all variable assignments in a function store the value in the local symbol table.
    একটি ফাংশন সম্পাদন ফাংশন স্থানীয় ভেরিয়েবল জন্য ব্যবহৃত একটি নতুন প্রতীক টেবিল পরিচয় করিয়ে দেয়। আরও স্পষ্টভাবে, একটি ফাংশনে সমস্ত পরিবর্তনশীল অ্যাসাইনমেন্ট স্থানীয় প্রতীক টেবিলের মধ্যে মান সংরক্ষণ করে।
    On the other hand, variable references first look in the local symbol table, then in the local symbol tables of enclosing functions, then in the global symbol table, and finally in the table of built-in names. Thus, global variables cannot be directly assigned a value within a function (unless named in a global statement), although they may be referenced.
    অন্যদিকে, পরিবর্তনীয় রেফারেন্সগুলি প্রথমে স্থানীয় প্রতীক টেবিলটিতে, তারপরে ঘেরের ফাংশনগুলির স্থানীয় প্রতীক টেবিলগুলিতে, তারপরে বৈশ্বিক প্রতীক সারণীতে এবং অবশেষে অন্তর্নির্মিত নামের সারণিতে প্রদর্শিত হয়। সুতরাং, গ্লোবাল ভেরিয়েবলগুলি কোনও ফাংশনের মধ্যে সরাসরি কোনও মান নির্ধারণ করা যায় না (যদি কোনও বিশ্বব্যাপী বিবৃতিতে নাম না দেওয়া হয়) তবে তাদের উল্লেখ করা যেতে পারে।


    >>> a = 1
    >>> b = 10
    >>> def fn():
    ...     print(a)    # local a is not assigned, no enclosing function, global a referenced.
    ...     b = 20      # local b is assigned in the local symbol table for the function.
    ...     print(b)    # local b is referenced.
    ...
    >>> fn()
    1
    20
    >>> b               # global b is not changed by the function call.
    10

    The actual parameters (arguments) to a function call are introduced in the local symbol table of the called function when it is called. In this way, arguments are passed using call by value (where the value is always an object reference, not the value of the object). When a function calls another function, a new local symbol table is created for that call.
    কোনও ফাংশন কলের আসল প্যারামিটারগুলি (আর্গুমেন্টগুলি) যখন ডাকা হয় তখন ডাকা ফাংশনটির স্থানীয় প্রতীক টেবিলটিতে প্রবর্তিত হয়। এইভাবে, যুক্তি দ্বারা মান দ্বারা কল ব্যবহার করে পাস করা হয় (যেখানে মানটি সর্বদা অবজেক্টের রেফারেন্স হয়, বস্তুর মান নয়)। যখন কোনও ফাংশন অন্য ফাংশনকে কল করে, তখন এই কলটির জন্য একটি নতুন স্থানীয় প্রতীক টেবিল তৈরি করা হয়।













  • 0 comments:

    Post a Comment

    New Research

    Attention Mechanism Based Multi Feature Fusion Forest for Hyperspectral Image Classification.

    CBS-GAN: A Band Selection Based Generative Adversarial Net for Hyperspectral Sample Generation.

    Multi-feature Fusion based Deep Forest for Hyperspectral Image Classification.

    ADDRESS

    388 Lumo Rd, Hongshan, Wuhan, Hubei, China

    EMAIL

    contact-m.zamanb@yahoo.com
    mostofa.zaman@cug.edu.cn

    TELEPHONE

    #
    #

    MOBILE

    +8615527370302,
    +8807171546477