python me coding kaise kare | First program in python | Python Hindi Notes

python me coding kaise kare | First program in python | Python Hindi Notes

पाइथन में कोडिंग कैसे करें?

(How to do coding in Python?)


पाइथन में कोडिंग कैसे करें


अभी तक हमने सिखा पाइथन का परिचय ,पाइथन की विशेषताएं और

  पाइथन को कैसे कंप्यूटर में डाउनलोड कर इनस्टॉल करते है | आज हम

 पाइथन प्रोग्रामिंग में अपना पहला प्रोग्राम बनायेंगे जिसमे हम सीखेंगे की

 किस तरह कोड लिखने के लिए फाइल क्रिएट करते है और कोड लिखने के

 बाद किस तरह प्रोग्राम को रन कर आउटपुट देखते है |


  We will make our first program in Python programming, in which we will learn that

  how to create a file to write code and write code

  After running the program, how do we see the output?)


पाइथन में कोड लिखने के लिए  निम्न चरणों का पालन करें -

(Follow these steps to write the code in Python -)

1.) सबसे पहले visual studio code ओपन करें (first open visual studio code)

2.) ctrl + ~ से bash terminal ओपन करें | (Open bash terminal with ctrl + ~.)

first program in python in hindi

3.) पाइथन फाइल क्रिएट करने के लिए यहाँ Touch Command type करें touch के बाद अपनी फाइल का जो नाम देना हो वह टाइप करे और अंत में .py ज़रूर जोड़ देंगे क्यूंकि यह पाइथन फाइल है पाइथन फाइल एक्सटेंशन .py होता है  जैसे Touch Filename.py  

(To create a Python file, type Touch Command here, after touch, type the name of your file and you will definitely add .py at the end because it is a Python file Python file extension is .py like Touch Filename.py)


इस पोस्ट के अंत में gitbash में उपयोग होने वाली कुछ प्रमुख कमांड बताई गयी है उन्हें भी ज़रूर देख लें |

 (At the end of this post, some of the major commands used in gitbash have been mentioned, make sure to see them too.)


4.) कोड लिखने के लिए अब code command टाइप करें जैसे code Filename.py (To write code now type code command like code Filename.py)

python first program in vs code (python notes hindi)

5.) अब आप देखंगे ऊपर की तरफ फाइल ओपन हो जाएगी यहाँ हमे अपना कोड लिखना है |

(Now you will see that the file will open above, here we have to write our code.)

6.) एक साधारण प्रोग्राम जो केवल एक मेसज प्रिंट करेंगा यह केवल समझने के लिए है |

(A simple program that will print only one message is for comprehension only.)


printf("Welcome To Gnb classes This is My First Program")


Ctrl + S दबा कर सेव ज़रूर कर लें | 

(Make sure to save it by pressing Ctrl + S.)


type first program in python notes in hindi


7.) outout देखने के लिए टर्मिनल में python filename.py टाइप करें 

(type python filename.py in terminal to see out)

run first program in python


8.) टर्मिनल में आउटपुट आ जायेगा | तो इस तरह हम अपना प्रोग्राम बना सकते है | अब आप इसमे और भी मेसज जोड़ सकते है जैसे-  

(Output will come in terminal. So in this way we can make our program. Now you can add more messages to it like...)


print("Welcome To Gnb Classes")

print("My first Program")

print("Bye bye")

टर्मिनल पर आउटपुट देखने के लिए टर्मिनल पर python filename.py टाइप कर रन करें |

(To see the output on the terminal, type python filename.py and run it.)


GitBash में उपयोग होने वाली कुछ प्रमुख कमांड -

(Some of the major commands used in GitBash are -)

git bash commnad in hindi (python notes in hindi)


GitBash जैसे आपको पहले समझाया था यह फाइल को मैनेज करने के लिए उपयोग किया जा रहा है  इसकी मदद से हम पाइथन के लिए फाइल क्रिएट डिलीट रन आदि  काम कर सकते है - 

(GitBash as explained to you earlier it is being used to manage files, with the help of this we can do file create delete run etc work for python -)


1. PWD (Print Working Derctory) - इस command की मदद से हम यह ता कर सकते है कि अभी हम किस डायरेक्टरी में काम कर रहे है | उसक path हम देख सकते हैं |

(PWD (Print Working Derctory) - With the help of this command, we can find out in which directory we are working now. We can see its path.)


Syntax -  pwd (Enter) 


2. Ls (list) - इस command की मदद से हम अपने डायरेक्टरी (फोल्डर) में सभी फाइल्स की लिस्ट को देख सकते है | 

(Ls (list) - With the help of this command, we can see the list of all the files in our directory (folder).)


Syntax - ls (Enter) 


3. Mkdir( Making Directory) - mkdir से हम कोई भी फोल्डर या डायरेक्टरी बना सकते है | 

(Mkdir( Making Directory) - With mkdir we can create any folder or directory.)


Synyax - mkdir Name (enter)


4. Touch - टच command की  मदद  से हम फाइल क्रिएट कर सकते है यह फाइल उसी डायरेक्टरी (फोल्डर) में सेव होगी जहाँ हमने यह command लगाई है | 

(Touch - With the help of touch command, we can create a file, this file will be saved in the same directory (folder) where we have put this command.)


Syntax - touch Filename (enter)


5. Code - इस command की मदद से हम बनी हुई फाइल को एडिट कर सकते है अर्थात्  उसमे कुछ भी लिख सकते है | 

( Code - इस command की मदद से हम बनी हुई फाइल को एडिट कर सकते है अर्थात्  उसमे कुछ भी लिख सकते है | )


syntax - code filename (enter)


6. cd (change Directory ) - cd की मदद से हम किसी भी फोल्डर (डायरेक्टरी ) में जा सकते है | 

(cd (change directory) - With the help of cd, we can go to any folder (directory).)


Syntax - cd DirectoryName (enter) 


7. cd .. - जब हम cd से डायरेक्टरी के अंदर जाते है उसके बाद हम cd .(cd space dot dot ) की मदद से डायरेक्टरी के बहार आ सकते है |

(cd .. - When we go inside the directory from cd, after that we can come out of the directory with the help of cd .. (cd space dot dot).)


Syntax - cd .. (Enter)  


आगे हम Escape Sequences बारे में जानेंगे 

(Next we will learn about Escape Sequences)

explain Escape Sequences in python with example



यदि आप चाहते है कि print में जो भी लिखे वह न्यू लाइन से प्रिंट हो उसके लिए आपको \n का उपयोग करना होगा और इसी प्रकार यदि आप " " प्रिंट करना चाहते है तो आप \" लिखना होगा |

\ लिखने के लिए आपको दो बार  \\ लिखना होगा 

" लिखने के लिए \" लिखना होगा कुछ उदहारण निचे दिए गये है -

जैसे -

(If you want that whatever you write in print, you have to use \n for it to be printed with new line and similarly if you want to print " " then you have to write \".


To write \ you have to write \\ twice


To write "\" some examples are given below -

As-)

1.)

print("Hello my name is Ram")

Output - 

Hello my name is Ram

print("Hello \n my name is Ram")

output - 

Hello
my name is Ram 

-------------------

2.)

print(" My name is "Ram" ")  

Output 

Error 

-----------------------------

print("My Name is \"Ram\" ")

Output 

My Name is "Ram"

explain Escape Sequences in python with example hindi notes.png



Escape Sequences

\b  - Backspace

\n – New Line

\t  - Tab

\\ - Backslash

\” – Double Quote “

\’ – Single Quote ‘




Example 

print("Ram Shh\barma")

output - Ram Sharma

---------------------------

printf("Ram  \n Sharma")

output -

Ram 

Sharma

-----------------------------

print("Ram \t Sharma")

output

Ram         Sharma

------------------------------

print("Ram Sharma s\\o Suresh Sharma")

output

Ram Sharma s\o Suresh Sharma 

--------------------------------

print("Ram \"Sharma\" ")

output

Ram "Sharma"

----------------------------------

print("Ram \' Sharma\' ")

output

Ram 'Sharma'

----------------------------------

तो इस तरह आप अपने टेक्स्ट के साथ स्पेशल सिंबल को प्रिंट कर सकते है चूँकि ", \ , ' यह सिंटेक्स का हिस्सा होते है इसलिए इन्हे ऊपर बताये गये तरीको से ही लिखा जा सकता है | 

(So in this way you can print special symbols with your text, since ", \, ' are part of the syntax, so they can be written in the same way as mentioned above.)

Next - पाइथन वेरिएबल 

Pre. -  VS Code के साथ GitBase मिलाना

पिछली पोस्ट - पायथन का परिचय 

पिछली पोस्ट - पाइथन की विशेषताए क्या है?

पिछली पोस्ट - python , vs code, gitbash कैसे डाउनलोड करें?

पिछली पोस्ट - पाइथन में कोडिंग कैसे करें?

Please Do Not Enter Any Spam Link in The Comments Box

Post a Comment (0)
Previous Post Next Post