Python Book in Urdu Language Famous by Muhammad Umair Allah Ditta

November 16, 2022 | Author: Anonymous | Category: N/A
Share Embed Donate


Short Description

Download Python Book in Urdu Language Famous by Muhammad Umair Allah Ditta...

Description

 

   ‫ئ‬

  

‫ا‬‫و‬   ‫ن‬‫ز‬ ‫و‬‫د‬‫ر‬‫ا‬ 

‫د‬‫ا‬ 

 

umairallahditta@gmail com  com  Phone No: 

0306-2535801 

1

 

 

  

‫ان‬  ‫ب‬  

‫رف‬    ‫ ئ‬ 

‫؟‬    ‫۔‬1  ‫ا‬      ‫ئ‬‫۔‬2  ‫ئ‬       ‫ل‬‫ںا‬    3    ‫ئ‬       ‫ں‬‫ز‬‫ز‬ ‫د‬ ‫ا‬‫و‬‫۔‬4 (Syntax)    ‫ئ‬   ‫ل‬‫ا‬      ‫۔‬5 ‫ر‬‫ا‬    ‫ئ‬‫۔‬6



 

‫ر‬ ‫و‬ ‫ا‬ ‫ا‬ PyCharm 1

isual studio code PyCharm

  ‫ڈ‬‫۔‬1  SQL Alchemy‫ر‬  ‫ڈی‬ ‫۔‬2 Git visualization in editor  3

 ‫ڈ‬ 

4 5 )Local History( 6     ‫۔ر‬7 GUI  ‫چرم‬ ‫۔‬ ‫۔‬8 ‫ا‬VS Code 2  The Activity Barr  1 The integrated terminal 2       ‫۔‬3 Extensions 4

 ‫او ان‬ 2

‫رٹ‬ ‫د‬

5



 

 ‫ت‬‫ر‬ ‫ےاور‬ 6    ‫ ئ‬       ‫دی‬ -   

    ‫م‬‫ا‬‫و‬  ‫ئ‬    ‫ئ‬ 1   ‫اڈ‬  ‫۔‬2 ‫ظ‬‫ظا‬ 3 ‫ اورا‬ 4 5 Statements  6 Quotation in Python            ‫ئ‬‫۔‬7 ‫ا‬    Waiting for the user ‫۔‬8    ‫۔‬9 Command line Argument 10

 

3



 

‫ب‬     

‫رف‬ 

   ‫ئ‬

 ‫؟‬  

‫۔‬1 

       ‫ا‬  ‫ئ‬ ‫م‬‫ز‬‫و‬‫ر‬  ‫وان‬ ‫و‬ ‫ر‬ ‫ا‬‫ا‬   ‫ا‬ ‫ا‬   ‫و‬   ‫ل‬             ‫ئ‬     ‫ا‬)   ( ‫ہ‬‫ا‬ ‫ا‬

 ‫۔‬ ‫ر‬  ‫ر‬ ‫ا‬ ‫ا‬     ‫اس‬2008   1991‫و‬  

 ‫اس‬ ‫۔‬     ‫ت ئ‬ ‫و‬     ‫ت‬  ‫د‬     ‫ل‬‫ا‬     ،     ،    ‫ن‬    ‫و‬   ‫ا‬        ‫ئ‬        ‫لل‬‫۔‬  ‫رم‬  ‫اور‬cloud, DevOps, data science, data analytics, machine learning    ‫۔‬‫ر‬ ‫ر‬‫ر‬‫ذ‬  natural language processing  

 ‫ل‬‫ا‬‫ں‬ ‫ں‬‫ذ‬ ‫ذ‬‫ر‬     ‫ئ‬  ،، ) ‫ور‬(‫ڈو‬ ‫۔و‬1 ،، ‫ڈو‬ ‫و‬   2  ‫ر‬ ‫ ر‬3  ‫ا‬‫۔‬4 4

 

   ‫ئ‬

‫ا‬   2      

  ‫ور‬     ‫ا‬‫لو‬‫ا‬  ‫ئ‬ ‫۔‬      ‫ئ‬   ‫ل‬‫ا‬        ‫و‬       ‫ؤ‬  ‫م‬ ‫۔‬      ‫ئ‬ ‫ر‬‫و‬‫ا‬‫ھ‬  ‫ں‬ ‫۔‬   ‫را‬    ‫ڈ‬    ‫۔‬      ‫ئ‬   ‫و‬ ‫اد‬‫ےا‬ ‫ا‬     ‫مد‬‫ا‬  ‫رر‬ ‫ہ‬‫ر‬  ‫و‬‫ا‬  ‫ر‬ ‫۔‬       ‫ئ‬ ‫و‬  ‫و‬   ‫ی‬‫ر‬ ‫وڈ‬  ،،   ‫و‬ ‫ر‬‫ر‬ ‫ل‬‫ا‬    ‫۔‬          

  ‫ئ‬     ‫ل‬‫ںا‬      3

   ‫ئ‬       )‫ہ‬‫و‬،   ‫ی‬ ‫ی‬  ‫را‬ ،، ، ، ، ، ‫ز‬‫و‬ ‫و‬(‫ر‬    

   ‫م‬   ‫ئ‬ ‫۔‬   ‫۔‬  ‫م‬ ‫ا‬‫ح‬  ‫ن‬‫ز‬ ‫ی‬‫ا‬ ‫ا‬        ‫ئ‬             ‫ں‬   ‫ں‬‫ز‬‫ز‬ ‫ا‬‫و‬‫ی‬‫دو‬  ‫ں‬‫ا‬‫و‬  ‫ز‬ ‫ڈو‬   ‫۔‬   ‫د‬‫ت‬‫ز‬     ‫ا‬    ‫ئ‬        ‫ڈ‬‫اس‬ ، ،   ‫م‬     ‫ا‬     ‫و‬ ‫و‬      ‫س‬‫۔ا‬      ‫آ‬‫ر‬‫د‬    ‫اس‬

‫۔‬   5

 

   ‫ئ‬

(Syntax)   

    ‫ں‬‫ز‬‫ز‬ ‫د‬    ‫ا‬‫و‬‫۔‬4

   ‫ئ‬    ‫خ‬‫ر‬ ‫اثو‬ ‫ر‬ ‫ر‬  ‫اس‬ ‫اور‬،             

   ‫ ئ‬  ‫ن‬‫ز‬ ‫ی‬‫ا‬ ‫۔‬  ‫ا‬   ‫ا‬‫و‬ ‫ی‬  ‫و‬‫د‬،     ‫ل‬‫ا‬  ‫ں‬          ‫۔‬ ‫ل‬ ‫ل‬‫ا‬       ‫ا‬     ‫ں‬ ‫ز‬ ‫ز‬    ‫ئ‬   ،،     ‫ل‬‫ا‬     ، ،    ‫و‬ ‫و‬ ‫ر‬ ‫ہ‬ ‫ا‬‫د‬    ‫ا‬‫و‬ ‫۔‬‫ہ‬ ‫ا‬‫د‬  ‫ں‬ ‫ر‬‫و‬‫ا‬‫ل‬‫ا‬،loops   ‫ ۔‬ ‫ر‬‫ا‬ ‫ا‬ ‫ا‬  ‫ل‬ ‫ل‬‫ا‬       ‫س‬‫ا‬  ‫ا‬  ‫ز‬‫ز‬ ‫ی‬     ‫و‬‫د‬      ‫ئ‬       5  ‫ا‬    ‫ئ‬  ‫۔‬           ‫ئ‬  ‫ ۔‬  ‫ل‬‫ا‬       ‫ئ‬   ‫ر‬‫و‬‫ا‬ ‫ے‬‫ر‬     ،،   ‫ ا‬   Windows PC ‫پ‬   ‫آ‬ ‫آ‬    :  ‫ذ‬ ‫ر‬  )cmd.exe(    ‫ش‬ ‫ش‬  ‫ر‬‫ٹ‬   ‫ر‬  ‫ا‬  

    

inux



ac inux    ‫ا‬ ‫ل‬  :‫ا‬     ‫پ‬ ‫آ‬  ‫ر‬‫و‬‫ا‬    ac   

   ‫ئ‬

  ‫ا‬      ‫ا‬ ‫آپ‬     ‫م‬   ‫آپ‬ ‫ا‬ : ‫ڈ‬ ‫ڈ‬ ‫ن‬‫ؤ‬‫ا‬‫ڈ‬     ‫و‬‫ذ‬ ‫ر‬ ‫ا‬ ‫آپ‬  ،،  https://www.python.org/

6

 

   ‫ئ‬

‫ٹ‬‫ر‬  ‫ا‬        ‫۔‬6    ‫ئ‬       ‫س‬ ‫ا‬  ،        ‫ا‬   ‫و‬   ‫ہ‬           ‫ا‬      ‫ئ‬       ‫ر‬      ‫و‬‫ڈ‬    ‫ا ئ‬‫آپ‬   ).py)     ‫ا‬ ‫ا‬ ‫ا‬ ‫ا‬    ‫ڈالد‬    ‫ٹ‬‫ا‬ ‫ا‬  ‫ا‬  ‫ا‬   ‫اورا‬     ‫ئ‬    ‫ح‬  ‫س‬‫ا‬           ‫ا‬      ‫ئ‬

 ‫م‬       ‫پ‬  ‫آ‬  "helloworld.py"‫ں‬     ‫ئ‬   ،،    ‫ر‬‫و‬‫ر‬     ،،   ‫۔‬   ‫آ‬  ‫ا‬   print((“Hello World!”) print

‫ی‬  ‫ا‬‫ا‬‫ڈ‬ ‫اس‬،         ‫ا‬‫۔‬ ‫ظ‬    ‫ا‬.‫ن‬‫آ‬‫ا‬  

: ‫اور‬،     ‫ظ‬  ‫ا‬ ‫آپ‬ ‫ں‬  : ‫آوٹ‬    ‫اس‬

 

7

 

‫ب‬  

‫اور‬

isual studio code PyCharm

‫ا‬PyCharm 1

   ‫ا‬‫و‬   ‫ل‬‫ا‬  ‫ن‬‫ز‬ ‫ا‬ ‫ا‬    ‫ئ‬PyCharm 

(Integrated development environment Software) IDE    ‫ؤں‬  ‫ج‬‫ر‬‫د‬     ‫رڈ‬  ‫او‬‫ر‬ ‫ا‬   ‫۔‬    ‫ر‬‫و‬‫ا‬  ‫ڈ‬ 1  ‫ڈ‬ ‫ر‬‫د‬  ‫ا‬ 2 ‫و‬   ‫ک‬‫ر‬‫و‬ ‫ر‬ ‫ر‬‫و‬‫ا‬ ‫ا‬‫و‬ ‫و‬   ‫اور‬   3       ‫ڈ‬  ‫و‬  ،، ‫وہ‬  ‫اس‬  ‫ے‬ ‫س‬ ‫ را‬   ‫م‬   PyCharm  ‫ڈ‬ 1 ‫چ‬          ‫در‬PyCharm     ‫ اس‬  ‫و‬ SQL Alchemy‫ر‬  ‫ڈی‬ ‫۔‬2 ‫ و‬   ،،      ‫ا‬ ‫آپ‬  SQL representation  ‫رف‬  ‫ڈ‬ ‫اور‬     PyCharm

 

8

 

Git visualization  in editor  3    ‫ئ‬   ‫ت‬‫ا‬ ،، ‫و‬   ‫ڈ‬   

‫ت‬  ‫ل‬       ‫ڈ‬ ‫ اس‬     ‫آ‬   ‫ق‬

‫در‬

‫آ‬

‫ہ‬‫د‬  ‫ر‬‫و‬‫ا‬

 ‫چرم‬

‫ آپ‬

   ‫آ‬    ‫و‬ ‫و‬

 ‫ڈ‬

 4     ‫ں‬.py   PyCharm‫آپ‬  ،،‫ی‬ ‫و‬‫ر‬  ‫ر‬  ‫ڈ‬  ‫س‬‫ا‬ ‫ ۔‬   ‫ن‬ ‫و‬ 5      ‫د‬ ‫ ی‬   ‫م‬  ‫ہ‬‫د‬  ‫ل‬‫ا‬    ‫اور‬ ‫دہ‬ ‫ل‬‫س ا‬‫۔ا‬         ‫ر‬ ‫اور‬ ‫ش‬ )Local History(‫۔‬6 ‫ر‬

Local History  ‫ح‬    ‫س‬‫ا‬  ‫ز‬  ‘Git’, ‘complements’            7    ‫م‬ ‫ں‬‫ دہ‬  ‫و‬         smooth  ‫چر‬  ‫او‬    

     ‫ٹ‬‫ر‬     9

 

GUI  PyCharm‫ٹ‬

GUI 

 

‫چر‬ ‫۔‬ ‫۔‬8

‫ا‬  ‫د‬ ‫ا‬      ‫ہ‬‫۔‬ ‫۔‬ ‫د‬     import  ‫و‬ ‫ہ‬‫د‬     

 

 ‫آپ‬ ،، ‫ٹ‬   ‫ر‬  ‫ں‬    ‫اورر‬

‫ا‬ ‫د‬   ‫د‬‫ و‬‫ا‬ ‫و‬ ‫دہ‬‫ر‬   ‫ ۔‬   ‫ں‬‫و‬‫ر‬  ‫د‬ official  ‫س‬‫را‬‫و‬‫ ا‬ ‫ڈ‬ ‫ن‬‫ؤ‬‫ا‬‫ڈ‬  PyCharm‫آپ‬  ‫ ۔‬ ‫ھ‬   ‫اس‬documentation

https://www.jetbrains.com/pycharm/  

10

 

‫اا‬VS Code  ‫ل‬‫وراورا‬ ‫ط‬  Visual studio code 

2

 ‫ن‬‫آ‬   ‫ا‬   ‫و‬        ‫ڈ‬       ‫و‬ ‫ت‬‫ر‬‫و‬  ‫ا‬     ،   ‫رٹ‬ ‫ز‬‫ا‬‫و‬ ‫ دہ‬ ‫ا اور‬‫ا‬ –  ‫ل‬ ‫ا‬free   ‫اا‬ ‫۔‬  ‫ا‬  ‫ڈ‬ ‫ ی‬  ،، ‫ ی اپ‬     ‫ ؟‬   ‫م‬  The Activity Barr  1



   ‫ڈ‬VS ‫آپ‬ ‫ر‬    ‫ت‬‫ز‬  ‫ا‬ ‫م‬ ‫در‬    ‫ڈ‬  ‫و‬ ‫ آپ‬The Explorer ‫۔‬1 ‫رر‬‫ا‬ ‫و‬ ‫دہ‬  ‫ا‬‫پ‬‫آ‬ ‫ں‬ ‫وہ‬ 

Search   2 ‫ص‬   ‫ں‬     ‫و‬   ‫ا‬   ‫پ‬ ‫آ‬ ‫۔‬  ‫ت‬‫ز‬  ‫ا‬    ‫ ا‬   ‫ش‬ ‫ڈ‬     ‫ول‬ ‫رس‬   ‫ ائ‬Source Control Management 3 it   ‫۔‬ ‫ا‬   ‫ا‬      ‫و‬   ‫ئ‬           ‫ڈ ا‬ ‫ ی‬      ‫م‬  4 ‫ ۔‬   ‫م‬  

11

 



 ‫ ا‬VS Code  ‫آپ‬Extensions‫۔‬5 improved support  ‫ں‬‫ز‬ ‫ز‬ ‫ر‬  ‫ل‬ ،، ‫تد‬  ‫ز‬  ‫ا‬        ‫ ئ‬ VueRectangular ،،   ‫ ور‬    The integrated terminal 2   ‫ا‬  ‫پا‬  ‫آ‬ ،، ‫ڈ‬  ‫ا‬  ‫و‬ ‫ژ‬  ‫و‬   ‫ئ‬  ‫ل‬    ‫ا‬ Root

Work Space‫ا‬  ‫ن‬‫آ‬‫۔‬     ‫ز‬‫و‬ ‫و‬  ‫پ‬‫آ‬   ‫مد‬‫ا‬     ‫ت‬‫ر‬‫و‬     Existing terminal

 

      3

‫ا‬‫و‬ ‫و‬‫ا‬ VS Code         VS Code           SHIFT + CMD        

 ‫ن‬‫دہآ‬

‫اور‬  ‫ش‬ ‫ت‬     ‫آپ‬           ‫ذر‬ + P  ‫ر‬  ‫ل‬‫ ۔‬  Navigate ‫ڈ‬VS‫اور‬     Done ‫ "درج‬"Latter  ‫ا‬       

  12

 

Extensions 4  ‫ڈ‬VSExtensions 

  

 ‫ا‬      ‫ر‬    VS Code  ‫ اا‬ JavaScript out of the box

  ‫ ا آآ‬ Extension  ‫وی‬    Angular Essentials extension by John Papa  ‫ ۔‬   ‫ڈ اا‬‫ا‬ ‫ف‬‫ ۔‬     ‫آ‬ ‫آ‬ ‫ا‬       ‫ڈ‬ ‫ہ‬‫ر‬ ‫و‬‫د‬،    ‫ل‬‫ا‬‫اورا‬ ‫ش‬Extension   ‫ا‬ ‫۔‬ ‫ں‬   ‫ب‬‫تد‬   5     ‫ا و ر ان‬ ‫ر‬‫دہ‬   ‫دد‬ VS Code    ‫ڈ‬ ‫ر‬   ‫ٹ‬   ‫ر‬  ‫ا‬   ‫ آ‬ ‫ا‬

‫ا‬ ‫ڈ‬ 

‫ا‬  ‫ٹ‬ ‫ر‬    ‫ن‬ ‫ا‬ ‫و‬ ‫ا‬  ‫ر‬ ‫ر‬  ‫آپویا‬  ‫۔‬ ‫ش‬ ‫وں‬‫ن درج‬

To enter this, simply press and hold CMD and enter K + S on the keyboard.

13

 

 ‫ر‬‫ز‬‫و‬ ‫و‬ ‫۔‬ ‫دے‬     ‫رٹ‬  Mac OS ‫آر‬  ‫رٹ‬  ‫و‬‫و‬    ‫وں ا‬ !

CTRL(



‫ٹ‬ Press  ‫ر‬ ‫رڈ‬ ‫ور‬‫)ا‬،، ‫در‬K +S‫ اور‬

‫ز‬   ‫لل‬ SHIFT + CMD + P

opens the command palette, “Show All Commands”

SHIFT + CTRL + ´

opens the integrated terminal, “Toggle Integrated Terminal”

CMD + D

   ‫ڈ‬

select next matching code, “Add Selection to Next Find Match”

ALT + CMD + Up Arrow Key

adds the cursor at the same position in the prior line, “Add Cursor Above”

ALT + CMD + Down Arrow Key

adds the cursor at the same position in the next line, “Add Cursor Below”

SHIFT + ALT + F

format the entire code page => Depending on the programming language, you might have to install an extension to activate this feature, “Format Document”

SHIFT + CMD + 7

comment out the selected code lines, “Toggle Line Comment”

CMD + ALT + A

comment out the selected code block, “Toggle Block Comment”

14

 

‫وو‬  CTRL + TAB

switch between open files in current project, “Open Next Recently Used Editor in Group”

CMD + P

switch between recently opened files, “Open Recent…“

CTRL + R

 

 

switch between projects, Open Recent…

 ‫ےاور‬

‫ع‬  ‫و‬ ‫اورا‬lite weight software

6



  ‫و‬ ‫۔‬     ‫ن‬‫ز‬ ‫ا‬‫و‬      (Syntax) ✓  ‫د‬ ‫د‬ ‫رٹ‬       ‫ن‬‫آ‬ ‫م‬ ✓  ‫و‬    HTML / CSS،، 

 

 ‫م‬ 

SIDE preview plugin

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,  

15

 

 

    ‫ئ‬        ‫ ی‬  

‫ب‬  

   ‫ئ‬

 ‫ں‬‫ز‬‫ز‬ ، ،‫۔‬ ‫۔‬ ‫ر‬      ‫وا‬ ‫ر‬‫و‬‫ا‬،  ،، ‫ل‬ ‫ن‬‫ز‬    ‫د‬ ‫ت‬  ‫ ئ‬  ‫ا‬ ‫صا‬      

‫م‬‫ا‬‫و‬  1

   ‫ا‬‫و‬ 

‫ا‬‫و‬   ‫آ‬ ‫ا‬‫و‬ ‫ڈ‬ ‫ ا‬1  ‫س‬  ‫ ا‬   ‫ا‬ ‫ا‬      ‫ہ‬‫ر‬  ‫ا‬  ‫ر‬    ‫ا‬ ‫ا‬  

Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32 Type "help", Type  "help", "copyright", "copyright" , "credits" "credits"   or or   "license"  "license" for more for more .  information. information >>>  >>> 

   ‫ئ‬

‫د‬-‫ اور‬  text  ‫ر‬ ‫ہ‬‫ر‬  ‫ا‬      ‫ئ‬      ‫ ئ‬ ‫ر‬  ‫آپ‬  ،،  ‫ر‬ ‫ن‬‫ژ‬‫ر‬‫و‬   ‫پ‬   ‫ا‬    ‫آ‬   ‫ن‬‫ژ‬‫ر‬‫و‬   ،،   ‫۔‬ print(“Hello, Python”)     ‫ل‬‫ا‬    ‫ا‬      ‫ا‬  ‫ذ‬ ‫ر‬  ،، 2.4.3

>>>  >>>  print  print "Hello, Python!" 

Hello, Python! 

‫ا‬‫و‬ ‫ڈ‬ ‫ا‬ ‫ ا‬2      ‫اا‬ ‫ ا‬ ‫اا‬   ‫ یر‬ ‫و‬ ‫و‬ ‫س‬‫ا‬‫ر‬‫و‬‫ا‬     ‫وع‬ ‫آ‬‫ر‬‫د‬    ‫ا‬ ‫را‬  ‫او‬ 16

 

،،     ‫ا‬ ‫ا‬ ‫۔‬    ‫ا‬ ‫ا‬      ‫ئ‬    ‫ئ‬ ‫۔‬ ‫ ر‬ ‫م‬  ‫ناب‬   ‫ ۔‬  ‫م‬‫ا‬‫و‬   ‫م‬  ‫ا‬ ‫ ا‬‫آ‬  ‫ڈ‬ ‫س‬‫ر‬  ‫درج‬

 test.py

‫۔‬. py

 ‫ں‬  ‫ ۔‬  

print( print ("Hello, Python!" Python!") ) 

   ‫ئ‬

   PATH‫س‬  ‫آپ‬    ‫ض‬         ‫ذ‬   ‫م‬‫ا‬‫و‬ ‫اس‬،   ‫۔اب‬ ‫ر‬

$ python test. test.py 

   ‫آ‬

Hello, Python! 

‫ذ‬ ‫ر‬  ‫اس‬    ‫ئ‬

‫را‬ ‫ا‬  ‫و‬‫د‬        ‫ا‬  ‫ا‬  ‫آ‬ ‫۔‬  test.py‫ہ‬  ‫۔‬‫ز‬  ‫ز‬‫آ‬ #!/usr/bin/python  #!/usr/bin/python   print print( ("Hello, Python!" Python!") ) 

‫ڈا‬usr / bin/ ‫س‬  ‫آپ‬   ‫ض‬          ‫م‬  ‫ا‬‫و‬ ‫اس‬، ‫۔اب‬ ‫د‬ $ chmod +x test. test.py ./test test. .py  $./

# This is to make file executable  executable  

17

 

Hello, Python! 

   ‫آ‬

‫ذ‬ ‫ر‬  ‫اس‬

   ‫ئ‬

    ‫ئ‬   ‫ڈ‬ ‫ا‬    ‫اور‬  ،، ‫س‬ ،،  ،،    ‫م‬    ‫اڈ‬    ‫۔‬2 a to z ZA ‫ہ‬   ‫۔ا‬   ‫ل‬‫ا‬     ‫ں‬ ‫ر‬‫و‬‫ا‬‫ر‬ ‫ر‬‫ا‬ ،، ‫وف‬ ‫ د‬  ‫ اس‬   )_(‫ر‬ ‫ر‬‫ا ا‬    ‫وع‬       ‫ ئ‬ )90(  ‫ت‬‫ز‬  ‫ا‬  ٪٪‫ر‬ ‫او‬، ،،، @  ‫ں‬‫دو‬ ‫ر‬‫ا‬‫ر‬‫ا‬          ‫ئ‬  ‫س‬ ‫ح‬  ‫س‬‫ا‬‫۔‬    ‫ا‬   ‫و‬    ‫اور‬ Manpower  ‫۔‬  ‫د‬ ‫ ۔‬ ‫ر‬    ‫دو‬manpower     ‫ئ‬  ‫ج‬‫ر‬‫د‬    ‫ں‬     ‫اڈ‬    ‫م‬ ‫م‬ ‫۔۔‬   ‫وع‬  ‫وف‬ ‫ے‬ ‫م‬conventioClass‫ں‬ ‫۔‬   ‫وع‬  ‫وف‬    ‫ہ‬‫ر‬  ‫ا‬ ‫آغز‬     ‫اڈ‬ ‫ر‬ ‫ر‬‫ا‬     •



 ‫ا‬   ‫اڈ‬    strongly private ‫آغ‬     ‫ اڈ‬  ‫ر‬ ‫ر‬‫ا‬‫دوا‬

    identifier    defined    ‫اڈ‬،،        ‫ر‬ ‫ر‬‫ا‬  ‫ دو‬   ‫اڈ‬‫ا‬ special name 18







 

 

   ‫ئ‬

  ‫د‬ ‫ظد‬‫ا‬     ‫ل‬‫را‬ ‫م‬      ‫اوراڈ‬



‫ظا‬

3

   ‫ رج‬   ‫پا‬   ‫رآ‬  ‫او‬ ‫ظ‬‫ظا‬  

and

exec

not

assert

finally

or

break

for

pass

class

from

print

continue

global

raise

def

if

return

del

import

try

elif

in

while

else

is

with

except

lambda

yield

‫ او ر ا‬

4

 ‫ر‬ ‫ز‬ ‫آپ‬      ‫ک‬   ‫ڈ‬     ‫ئ‬  ‫ا‬     ‫ڈ‬    ‫ا‬ ‫ا‬   ‫ا‬     ‫ک‬ ‫ ا‬          ،،      ‫ر‬  ‫ذ‬     ‫م‬‫ر‬‫ا‬ ‫ک‬ ،،   ‫اد‬  ‫ں‬   ‫ر‬  ‫ل‬ ‫۔‬‫چ‬   ‫ ا‬ ‫ر‬ ‫ا‬

if True: print "True"

else: print "False"  19

 

  

Error 

 ‫ک‬ ‫ذ‬ ‫ر‬ ، ، 

if True if  True: :  print print   "Answer" "Answer"    print   "True" "True"    print else: else:  print "Answer" print  "Answer"    print   "False"  print

   ‫ئ‬

   ‫م‬   ،، ‫ح‬‫س‬   ‫ا‬     ‫ل‬  ‫ر‬      ‫اد‬   ‫ں‬

‫پ‬‫آ‬ 

‫۔‬ ‫ٹ‬ ‫س‬‫ا‬ ‫ں۔‬   races ‫وہ‬ ‫چ‬ ‫چ‬

 

#!/usr/bin/python  #!/usr/bin/python   import import sys  sys try: try:  stream    # open file stream  open( (file_name file_name, , "w") "w")  file = open except IOError: except  IOError:  print   "There was an error writing to", to" , file_name print .exit exit() ()    sys. sys print  '", , file_finish  file_finish, ,  print "Enter '" print "' When finished" print  finished"    while file_text != file_finish: :  while file_text != file_finish file_text = raw_input  raw_input( ("Enter text: ") ")  if file_text  file_text == file_finish == file_finish: :  if # close the file  file  .close file. file break break    .write write( (file_text file_text) )  file. file file. file .write write( ("\n" "\n") )  .close close() ()    file. file  raw_input( ("Enter filename: ") ")  file_name = raw_input if len( if len (file_name file_name) ) ==  == 0:  20

 

print   "Next time please enter something"  something"  print sys. sys .exit exit() ()    try: try:  file = open  open( (file_name file_name, , "r") "r")  except  IOError:  except IOError: print print   "There was an error reading file"  file"   .exit exit() ()    sys. sys file_text = file  file. .read read() ()    .close close() ()    file. file print file_text  print file_text

Statements    

 ‫ئ‬ 

5

           ‫ر‬ ‫م‬     ‫ئ‬    ‫ت‬‫ز‬  ‫ا‬  ‫ل‬‫ا‬ )\(character     ،،   ،،     ‫ر‬ ‫ل‬ ‫ریر چ‬

total = item_one + \ item_two + \ item_three 

character        ‫د‬ ‫ر‬‫ا‬   )( ،، }{،، ][  ‫ر‬  ‫ل‬   ‫ت‬‫ر‬‫و‬     ‫ل‬‫ا‬

days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] 

Quotation in Python 6     



  ‫ اا‬   ‫ں‬‫و‬‫ر‬  ‫ا‬  ‫ر‬‫و‬‫ا‬‫ڈ‬ ،،    ‫ئ‬  )""" "" "'' '''(   )" "( ‫ڈ‬ ،، )''(  ‫۔‬    ‫ڑ‬   ‫وف‬  ‫ا‬   ‫ا‬ ‫ا‬  ‫ں‬‫ دہ‬ ‫ل‬‫ا‬    ‫م‬  ‫ر‬،  ، ‫ر‬  ‫ل‬ ‫۔‬  

word = 'word' sentence = "This is a sentence." paragraph = """This is a paragraph. It is

made up of multiple lines and sentences."""

21

 

 

   ‫ئ‬

   ‫ا‬ 

‫ ۔‬7

‫در‬،      ‫ہ‬‫و‬‫چ‬ ، ،  ‫ا‬‫ہ‬     ‫ں‬  ‫ح‬     ‫ز‬   ‫ک‬‫ر‬‫و‬   ‫ں۔ آپ‬ ‫ے‬       ‫ڈ‬ ‫ا‬‫ر‬‫و‬‫ا‬،    ‫د‬  ‫ر‬   ‫ہ‬    ‫ئ‬   ‫ا‬ ،،   ‫ے‬           ‫اا‬‫و‬‫ا‬ ‫ا‬   ‫ا‬ ‫۔‬  ‫اث‬ ‫و‬ ‫و‬      ‫وع‬    # ‫و‬ ‫و‬    ‫اس‬ ‫ے‬ Disturb      ‫اس‬

،،



‫م‬‫ا‬     ‫ ۔‬1       #  ‫وع‬ ‫وو‬ ‫ہ‬    ‫ئ‬   

    ‫ل‬‫ا‬ ‫۔‬   ‫ل‬‫ا‬

# This is my first Python script  script   print( print ("UMAIR" "UMAIR") ) 

‫ے‬ ‫اور‬

   ‫۔‬2    ‫ئ‬

 ‫وع‬     ‫ہ‬       ،،   ‫ل‬‫ا‬ )'''(‫ا‬ ‫آ‬



'''This book is  is  written by Muhammad Umair'''  Umair'''  a = "UMAIR" "UMAIR"    print(a) print (a)  

22

‫د‬

 

 ‫ہ‬ ‫ ا‬‫ا‬ ،،             )#(  ‫ان‬

Python inline comment 3  ‫ر‬    ‫ا‬ ‫ہ‬  ‫ا‬    ،، ‫ح‬ ‫ک‬‫۔‬  

     ‫وع‬  ‫ذ‬ ‫ر‬                  ‫ن‬‫ا‬‫ا‬‫ل‬ print( print ("UMAIR" "UMAIR") ) # This is inline coment  coment 

  ‫ا‬   ‫ا‬   ‫ف‬ ،،       ‫ر‬     ‫ئ‬    ‫د‬ ‫ز‬‫ا‬‫ا‬  ‫ر‬  ‫ا‬  ‫ر‬‫و‬‫ا‬       

Waiting for the user

‫۔‬

   ، ،    ‫رہ‬‫ا‬  ‫ر‬ ‫م‬‫ا‬‫و‬ 8 ‫ر‬  ‫ا‬ ‫ا‬user  ‫راا‬‫و‬‫ا‬، " ‫د‬ Enter      " raw_input( raw_input ("\n\n \n\nPress Press the enter key to exit." exit.") ) 

‫۔‬  

    ‫دو‬         ‫"ا‬n \ n\"،، ‫م‬  ‫ا‬‫و‬،   ‫رف دد‬  ‫ر‬ ‫۔‬  ‫ل‬‫ا‬   Trick ‫ہ‬      ‫ر‬   ‫و‬‫لو‬ ‫۔‬   ‫ے‬  ‫م‬  Application  ‫رف‬         ‫۔‬9  ‫ت‬‫ز‬  ‫ا‬ ‫ دہ‬   )‫(؛‬     ‫۔‬‫ے‬‫د‬‫وع‬ ‫ک‬ ‫ڈ‬  ‫ذ‬ ‫ا‬   ‫ل‬‫ا‬ 23

 

import sys;  sys; x = 'foo' 'foo'; ; sys.stdout.write(x + '\n \n' ')  import

Command line Argument 10   ‫آپ‬  ‫رے‬     ‫ا‬ ‫ت‬    ‫ی‬       ‫ان‬   ‫مدرج‬  ‫ا‬‫و‬ python -h usage: python [option] ... [-c cmd | -m mod | file file |  | -] [arg] ... Options and and arguments  arguments (and (and corresponding  corresponding environment variables): -c cmd : program passed in in   as as string  string (terminates option list list) ) -d : debug output from from parser  parser (also PYTHONDEBUG PYTHONDEBUG=x) =x) -E : ignore environment variables (such as as PYTHONPATH)  PYTHONPATH) -h : print print this  this help help message  message and and   exit exit    [ etc. ] ]  

 ‫ا‬      ‫ام‬‫و‬‫ح‬‫اس‬ ‫ا‬ ‫آپا ا‬ ‫ع‬  ‫ا در‬  ‫چ‬   ‫ل‬  ‫ل‬  ‫آ‬    ‫ئ‬    ‫اس‬‫ں‬    Concept ‫رے‬    ‫آپ‬ ‫ا‬‫ر‬‫و‬‫ا‬ ‫۔‬‫چ‬      ‫اس‬   Command Line Arguments

24

 

‫م‬‫ا‬‫ا‬ ‫یا‬‫و‬ ‫از‬

‫۔‬  ‫ا‬‫ری‬‫ص‬‫ہ‬‫ذ‬‫اتو‬  ‫ری‬‫پ‬‫آ‬  ‫پ‬‫آ‬    ‫س‬ ‫اس‬ ‫اا‬‫ری‬  ‫اا‬،‫د‬ ‫ڈ‬‫۔‬   ‫ظ‬ ،‫ا‬‫۔‬    ‫ظ‬    ‫ی‬ ‫ر‬        ‫ر‬ ‫و‬ ‫ا‬                   ‫ڈ‬،، ‫وں ا‬‫آپ س‬، ‫اا‬‫ڈ‬  ‫۔‬   

‫ر‬‫ا‬‫ا‬‫ات‬ 1

 ‫ا‬‫آوا‬ ‫د‬ ‫ظ‬ ‫ری‬‫ا‬‫۔‬  ‫از‬  ‫ر‬‫و‬  ‫پ‬  ‫دظ‬ ‫د‬ ‫ا‬    ‫ت‬ )=(‫ن‬‫وی‬ ‫اا‬‫و‬‫۔‬ ‫اا‬  ‫و‬ ‫۔‬  ‫ل‬‫ا‬ ‫ف‬‫دا‬ ‫اور‬‫م‬ ‫فآآ‬   ‫ر‬‫ل‬‫۔‬ ‫و‬     counter = 100 100    miles = 1000.0  1000.0  name = ("John”) 

# An integer assignment  assignment  # A floating point  point  # A string string   

print (counter) print (counter) print (miles) print  (miles) print (name) print  (name)  

‫م‬‫اور‬،  ،‫ؤ‬ ‫ؤ‬"‫ن‬ "‫ن‬"‫ اور"ر‬000.0،، 00،‫ں‬ ‫۔‬‫جذ‬ ‫ر‬‫د‬‫س‬‫ا‬‫۔‬‫ز‬‫و‬ ‫اا‬   25

 

100 1000.0 John 

  ‫پ‬ ‫داآ‬   ‫وو‬ ‫ات‬‫د‬ ‫از‬  ‫۔‬2

‫ر‬‫ل‬‫۔‬‫تد‬  ‫ز‬  ‫ا‬ ‫اا‬  

a = b = c = 1 

‫ئ‬  ‫ں‬ ‫آ‬   ‫ا‬ ،،‫ں‬ ‫د‬  ‫ر‬‫پ‬  ‫اضا‬  ‫م‬  ‫ا‬  ‫ا‬ ‫ا‬‫تو‬ ‫ری‬‫ا‬ ‫د‬ ‫ت‬‫ا‬   ‫ء‬ ‫ل‬‫آ‬ ‫۔‬ ‫۔‬ ‫ا‬   ‫ا‬

a,b,c = 1,2,"john" "john"  

‫ئ‬  ‫ اور‬‫آ‬ ‫وا‬‫د‬  ‫ اور‬‫و‬،،‫ں‬ ‫آ‬  ‫ن"وو‬""‫اورر‬،     ‫اا‬ ‫۔‬        ‫ا‬  ‫ا‬     ‫م‬‫ا‬‫رڈڈ‬ 3 ،‫ر‬‫ل‬‫۔‬‫ح‬‫رڈڈ‬‫ری‬  ‫رس‬ ‫س‬‫ا‬‫ر‬‫و‬‫ا‬  ‫ر‬‫ر‬‫کو‬   ‫۔‬‫ر‬ ‫ر‬‫وف‬ 26

 

‫آو‬‫ن‬‫ا‬‫م‬‫ا‬‫ر‬‫و‬‫اد‬‫ا‬ ‫و‬ ‫زز‬‫ا‬ ‫وو‬‫ر‬‫ر‬     ‫ن‬‫ا‬‫ر‬‫و‬‫ا‬ ‫۔‬‫ل‬   ‫ل‬‫ا‬ ‫۔‬‫م‬‫ریا‬‫ر‬‫و‬‫اد‬‫ا‬ ‫زز‬‫ا‬   

Numbers

 

String

 

List

 

Tuple

 

Dictionary











      ‫ز‬ ‫۔‬1

 ‫۔‬ ‫ر‬ ‫ز‬‫و‬‫ک‬ ‫م‬‫ا‬ ‫ڈ‬‫سوک‬ ‫۔‬ ‫ا‬ ‫ا‬  ‫ان‬ ‫ن‬ ‫آپ‬ ‫و‬   ‫ا‬    ‫آ‬   ‫ر‬‫ل‬ var1 = 1  var2 = 10  10 

‫رر‬‫آ‬‫ل‬‫ا‬‫ڈ‬‫آپ‬  ‫ر‬‫ل‬‫۔‬‫ڈ‬  

del var del var del var_a, del  var_a, var_b var_b  

‫۔‬‫رٹ‬‫م‬‫کا‬  ‫ر‬‫چ‬‫ز‬ ‫ز‬‫ا‬  

int (signed integers)

 

long (long integers, they can also be represented in octal and hexadecimal) hexadecimal)

 

float (floating point real values)

 

complex (complex numbers)









27

 

: ‫؛‬  ‫ں‬‫و‬  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

28

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF