Python Full Course In Hindi

Home About Us Contact Us Privacy Policy

Introduction

pythonn programming मे string ए क immutable data type हो ती है | string का उ प योग alphabets , numeber etc. को store करने के लिए किया जाता है | string के लिए double quotes("") या single quotes('') का उयोग किया जाता है |

string को create करना

string को double quotes("") या single quotes('') के अंदर लिखा जाता है |

🐍 Syntax
# double quotes मे string create करना st = "Hello World" # single quotes मे string create करना st = 'Hello World' # triple quotes मे string create करना st = ''' Delhi Is The Capital Of India '''
Output
Hello world
Hello world>
Delhi
Is
The 
Capital 
Of India

Tiple quotes के अंदर जैसे text लिखे जाते है | output window पर उसी तरह print होते है |

len()

len function एक Built-In function है | जिसके उपयोग से किसी string की lenght पता की जा सकती है |

🐍 Syntax
st = "Good Morning" print(len(st))
Output
12
  

String को access करना

python मे indexing 0 से शुरु होती है | किसी String मे store किसी text को access करने के लिए indexing का उपयोग किया जाता है |

🐍 Syntax
st = "Good Morning" print(st(0))
Output
G
  

string slicing

create की ग ई string मे से किसी निश्चित हिस्से (fixed part) को प्राप्त करने के लिए string slicing का उपयोग किया जाता है | इसके लिए colon(:) का उपयोग किया जाता है |

🐍 Syntax
st = "Good Morning" print(st[0 : 3])
Output
            Good 
          

string repeatation

एक string को एक से जयादा बार दोहराना |

🐍 Syntax
st = "Good\nMorning" print(st * 2)
Output
          Good Morning Good Morning
          

String जोड़ना

किन्ही strings को आपस मे जोड़ने के लिए (+) operator का उपयोग किया जाता है |
🐍 Syntax
st1 = "Good Morning" st2 = "Morning" add = st1 + "" + st2 print(add) print(st[0 : 3])
Output
Good Morning
  

Escape

string मे new line के लि ए \n का उपयोग किया जाता है |

🐍 Syntax
st = "Good\nMorning" print(st)
Output
Good
Morning