Wednesday, October 28, 2020

Getting started with phython

 Python is a high level programming language.

Python एक उच्च स्तरीय प्रोग्रामिंग भाषा है।

program written in high level language is called source code.

उच्च स्तरीय भाषा में लिखे गए प्रोग्राम को सोर्स कोड कहा जाता है।

translator 'interpreter'  needed to translate source code  into machine language in python.

python में सोर्स कोड को मशीन लैंग्वेज में अनुवाद करने के लिए Interpreter  की आवश्यकता होती है।

interpreter process program statements one by one until an error is encountered or the whole program is executed successfully.

interpreter  एक-एक करके तब तक translate  करता है जब तक कि कोई त्रुटि सामने नहीं आती या पूरा कार्यक्रम सफलतापूर्वक निष्पादित नहीं हो जाता।

Features of python (python की विशेषताएं )

1. It is free and open source.
(यह free  और open source है। )
2. python is case sensitive language.
(python  संवेदनशील भाषा है )
3. it is easy to understand due to its clear defined syntax.
( इसकी स्पष्ट परिभाषित वाक्य रचना के कारण इसे समझना आसान है। )
4. python has a rich library of predefined  funcntion.
( python के पास पूर्वनिर्धारित function  की समृद्ध library  है। )
5. python use interpreter to convert source code into machine code.
( स्रोत कोड को मशीन कोड में बदलने के लिए python  इंटरप्रेटर का उपयोग करता है। )
6. python is also helpful for web development.
( python  वेब विकास के लिए भी सहायक है। )

Execution Modes (निष्पादन मोड )

Two ways to use python interpreter ( python interpreter का उपयोग करने के दो तरीके )

1. Interactive Mode  ( इंटरएक्टिव मोड )
2. Script Mode  ( स्क्रिप्ट मोड )

1. Interactive Mode  ( इंटरएक्टिव मोड ) -

In this we mode we simply type a python statement on the prompt (>>> ) and press enter , interpreter executes the statement and display result.
इस मोड में हम बस प्रॉम्प्ट (>>>) पर एक python स्टेटमेंट टाइप करते हैं और एंटर दबाते हैं, Interpreter स्टेटमेंट वाक्यों को निष्पादित करता हैऔर परिणाम प्रदर्शितकरता है।
It is convenient for testing a single line but we cannot save the statement for future use.
यह एकल पंक्ति के परीक्षण के लिए सुविधाजनक है, लेकिन हम भविष्य में उपयोग के लिए statement को save नहीं कर सकते हैं

2. Script Mode  ( स्क्रिप्ट मोड ) -
We write a python program in a file, save it and then use the interpreter to execute it.
हम एक फ़ाइल में एक python program लिखते हैं, इसे save करते हैं और फिर इसे निष्पादित करने के लिए interpreter का उपयोग करते हैं

Keyword ( कीवर्ड ) -

words whose use and meaning is fixed.

ऐसे शब्द जिनका उपयोग और अर्थ निश्चित है।
keywords are also called reserved words.

कीवर्ड को आरक्षित शब्द भी कहा जाता है

Identifiers ( अभिज्ञानक )

Rules which are used to give names to various program elements are called identifiers.
नियम जो विभिन्न कार्यक्रम तत्वों को नाम देने के लिए उपयोग किए जाते हैं उन्हें अभिज्ञानक कहा जाता है।

Rules for naming an identifier 

 अभिज्ञानक के नामकरण के नियम )

1.  The name should begin with an Alphabet.

नाम की शुरुआत अंग्रेज़ी वर्णमाला से होनी चाहिए।

2. This name should be followed by combination of characters,               numbers and underscore.

पहले अक्षर के बाद यह नाम अक्षर, संख्या और अंडरस्कोर के संयोजन  होना चाहिए।

3. Identifier cannot be a keyword.

 अभिज्ञानक कोई कीवर्ड नहीं हो सकता।

4. we cannot use special symbol.

हम विशेष प्रतीक का उपयोग नहीं कर सकते।
5. it can be of any length but preferred to keep it short and meaningful.

यह किसी भी लम्बाई का हो सकता है लेकिन इसे छोटा और अर्थपूर्ण रखना पसंद किया जाता है।

Variables ( चर ) -

variables are used to store value and there value can be change during execution time.

वेरिएबल्स का उपयोग मूल्य को स्टोर करने के लिए किया जाता है और निष्पादन समय के दौरान मान में परिवर्तन किया जा सकता है।

Comments -

Comments are used to add a remark or a note in the source code  and remarks are not executed by interpreter.

Comments का उपयोग स्रोत कोड में एक टिप्पणी या एक नोट जोड़ने के लिए किया जाता है और टिप्पणी Interpreter द्वारा निष्पादित नहीं की जाती है

 In python we use 'Hash sign ' ( # ) for comment.

Python  में हम टिप्पणी के लिए 'हैश साइन' (#) का उपयोग करते हैं।

Datatypes in Python -

Q. Why everything is an object in python ?
Ans. Python treats every value as an object whether it is string, numeric or other type because every
         object in python is assigned a unique identity  which remains the same for lifetime of that object.
Q. पायथन में सब कुछ एक object  क्यों है?
उत्तर। पायथन प्रत्येक मान को एकobject के रूप में मानता है चाहे वह स्ट्रिंग, संख्यात्मक या अन्य प्रकार का हो              क्योंकि प्रत्येक पायथन में वस्तु को एक विशिष्ट पहचान सौंपी जाती है जो उस वस्तु के जीवनकाल के                 लिए समान रहती है।
Q. What is Bug.
Ans. Error in the program is called Bug.
Q. बग क्या है।
उत्तर। प्रोग्राम में त्रुटि को बग कहा जाता है।
Q. What is Debugging ?
Ans. Process of removing Bug in program is called  Debugging.
 Q. डिबगिंग क्या है?
उत्तर। प्रोग्राम में बग हटाने की प्रक्रिया डिबगिंग कहलाती है।
Type of Error - त्रुटि का प्रकार -
 Syntax Error - Every language has its own rules to determine the syntax. When we not follow these
                           rules error comes this type of error is called Syntax Error. 
                      Example-   
                                                     a=10
                                                     b=40
                                                     c= a+ b
                                                     print c
                                       In this program a syntax error occurs that we are not using paranthesis ( )
                                       with print.
सिंटैक्स त्रुटि - वाक्य रचना को निर्धारित करने के लिए प्रत्येक भाषा के अपने नियम होते हैं। जब हम इनका पालन नहीं करते हैं  नियम त्रुटि आती है इस प्रकार की त्रुटि को सिंटैक्स त्रुटि कहा जाता है।
                      उदाहरण-
                                                    a=10
                                                     b=40
                                                     c= a+ b
                                                     print c
                                       इस प्रोग्राम में एक सिंटैक्स त्रुटि होती है कि हम  प्रिंट के साथ। पैराथेसिस ( ) का                                                   उपयोग नहीं कर रहे हैं
                                    
Runtime Error -  Run time error occurs When the statement is correct syntactically but the 
                              interpreter cannot execute .
                  Example -   #Divide by zero error 
                                       a=8
                                       b=0
                                       c= a/b


                                       print(c)                              
  रनटाइम त्रुटि - रन टाइम त्रुटि तब होती है जब कथन वाक्य रचनात्मक(Syntactically ) रूप से सही होता है                                 लेकिन  interpreter इसे निष्पादित नहीं कर सकता                           
                                उदाहरण-     
                                       a=8
                                       b=0
                                       c= a/b
                                       print(c)    
Operators  - operators are symbols used to 
                        Perform mathematical and logical calculation
Types of operators -
Arithmetic operators - used to perform arithmetic calculation.
 Addition.      +.       Adds numeric values
 Subtraction.  -.       Subtracts numeric values      
Multiply.          *.      Multiplies numeric values
Divide.            /.        Divides numeric values
Modulus.        %.      Gives remainder
Floor division. //.      Gives quotient
Exponent.        **.       Perform exponential 
                                       Calculation
Example. -
                        a=10
                         b=25
                         c=a+ b
                         print c
Relation al operators - used to compare two or more values
Greater than.     >
Less than            <
Greater than equal to.    >=
Less than equal to <=
Equal to      ==
Not equal to !=

Example. -
                    a=10
                     b=22
                      c=a>b
                        Print c


Assignment operat.or - it is used to assign 
Value in variable
It takes value from right side and assign in left side variable
Type -
= , += , -= , *= , /= , %= , **=

Logical operator -
&&.      logical AND
||.        logical OR
!            logical NOT

It is used to compare two or more expression
Example 
                        a=10
                         b=5
                         c=2
                          d=(a>b)  && ( a > c)
                          print(d)
Identity operators -

Used to determine whether the value of a
Variable is of a certain type or not.
Type - is, is not

Membership operators -
Used to check if a value is a member of the given sequence or not 
Type - in , not in

Expression - combination of constants, variables and operators

Precedence of operators - 
 









                

No comments:

Post a Comment

if you have any doubt. please let me know.

Data communication

 Communication means exchange of data between two or more Devices. Components of data communication - 1. Sender.    2. Receiver.     3. Mess...