Python introduction and features
Python के सृजनकर्ता(creator) Guido van Rossum है। यह general purpose, हाई लेवल, डायनामिक, interpreted व objected oriented programming language है जो की 1991 में release की गयी।
Python से क्या किया जा सकता है?
Python का उपयोग कर निम्न applications develop किये जा सकते है।
- Software development
- Web development
Python Features
- Python cross platform सपोर्ट करता है याने इसका उपयोग अलग अलग operating system पर किया जा सकता है जैसे Windows, Linux, Mac OS इत्यादि।
- Object Oriented होने के कारण जिन्होंने c++, java, .NET सीखा हुए है वो Python बहुत आसानी से सीख सखते है।
- Python open source है इसका मतलब ये free है उपयोग करने के लिए।
- यह interpreted language होने के कारण rapid application development में उपयोग किया जाता है।
Download Python
आप python को python की official वेबसाइट से डाउनलोड कर उपयोग कर सकते है। यह फ्री है उपयोग के लिए।
Python Download link: https://python.org
Hello world python example
print("Hello World")
Python versions list and release date
| Python 3.8.0 | 14 October 2019 |
| Python 3.7.4 | 8 July 2019 |
| Python 3.7 | 27 June 2018 |
| Python 3.6 | 23 December 2016 |
| Python 3.5 | 13 September 2015 |
| Python 3.4 | 16 March 2014 |
| Python 3.3 | 29 September 2012 |
| Python 3.2 | 20 February 2011 |
| Python 3.1 | 27 June 2009 |
| Python 3.0 | 3 December 2008 |
| Python 2.7 | 3 July 2010 |
| Python 2.6 | 1 October 2008 |
| Python 2.5 | 19 September 2006 |
| Python 2.4 | 30 November 2004 |
| Python 2.3 | 29 July 2003 |
| Python 2.2 | 21 December 2001 |
| Python 2.1 | 15 April 2001 |
| Python 2.0 | 16 October 2000 |
| Python 1.6 | 5 September 2000 |
| Python 1.5 | 31 December 1997 |
| Python 1.4 | 25 October 1996 |
| Python 1.3 | 12 October 1995 |
| Python 1.2 | 10 April 1995 |
| Python 1.0 | January 1994 |
| Python 0.9.0 | 20 February 1991 |
Python download and install steps
Python को डाउनलोड करने के लिए python की official website https://www.python.org/downloads/ में जाकर सीधे डाउनलोड कर सकते है या फिर google.com में “Python download” लिखकर google करे और search results में python की official website से डाउनलोड करें।

Python की website open होने पर आपको yellow color में button दिखेगा जो भी latest version होगा वो डिस्प्ले होगा, उस पर click करने से डाउनलोड start हो जायेगा।

डाउनलोड कम्पलीट होने पर file पे double click कर open करने से installation start हो जायेगा, थोड़ी ही देर में installation complete होने पर installation successful का message दिखेगा।
Start menu के search में python type करने पर आपको python और उसके साथ अन्य जो install हुआ है वो लिस्ट करेगा search results में, आप उसमे IDLE editor दिखेगा और python shell देखेगा। IDLE editor का यूज़ कर python के प्रोग्राम डेवेलोप कर सकते है।
Python comments
# symbol से Python में comments दिए जाते है।
Comments का उपयोग code को समझाने के लिए किया जाता है के कौन सा कोड किस कार्य के लिए लिखा गया है ।
# symbol से Python में comments दिए जाते है।
Comments का उपयोग code को समझाने के लिए किया जाता है के कौन सा कोड किस कार्य के लिए लिखा गया है ।
Single line comment
# use hash/pound for comment
print('single line comment example') #comment can be written this way also
# use hash/pound for comment
print('single line comment example') #comment can be written this way also
Multiline comment
#multiline
#comment
#example
print('multiline comment example')
#multiline
#comment
#example
print('multiline comment example')
Python Keywords
keywords reserved words होते है जिनके मायने पहले से निर्धारित होते है निर्धारित operations के लिए, इनको variable के नाम जैसे उपयोग नहीं किया जा सकता है। Python में निम्न keywords उपलब्ध है।
and as asset break class
continue def del elif expect
for from if import in
is lamda nonlocal or global
pass raise not none try
true false finally return else
keywords reserved words होते है जिनके मायने पहले से निर्धारित होते है निर्धारित operations के लिए, इनको variable के नाम जैसे उपयोग नहीं किया जा सकता है। Python में निम्न keywords उपलब्ध है।
| and | as | asset | break | class |
| continue | def | del | elif | expect |
| for | from | if | import | in |
| is | lamda | nonlocal | or | global |
| pass | raise | not | none | try |
| true | false | finally | return | else |
Python Variables
Variables का उपयोग कर python में data को store या hold किया जाता है। Python में variables को declare किये बिना ही उपयोग किया जा सकता है।
age = 20
Variables का उपयोग कर python में data को store या hold किया जाता है। Python में variables को declare किये बिना ही उपयोग किया जा सकता है।
age = 20
variable के नाम रखने के नियम
- variable का नाम underscore या letter से शरू होना चाहिए।
- variable का नाम नंबर से शरू नहीं कर सकते है।
- case sensitive होते है variable के नाम python में।
- variable के नाम में alpha-numeric characters व underscore ही उपयोग किये जा सकते है।
- variable का नाम underscore या letter से शरू होना चाहिए।
- variable का नाम नंबर से शरू नहीं कर सकते है।
- case sensitive होते है variable के नाम python में।
- variable के नाम में alpha-numeric characters व underscore ही उपयोग किये जा सकते है।
Assign value to variable
age = 25
name = "Microsoft"
PI = 3.14
age = 25
name = "Microsoft"
PI = 3.14
Print/Output variable valueage = 25
name = "Microsoft"
PI = 3.14
print(age)
print(name)
print(PI)
name = "Microsoft"
PI = 3.14
print(age)
print(name)
print(PI)
Python numbers
Python तीन तरह के numbers सपोर्ट करता है।
- int
- float
- complex
Python तीन तरह के numbers सपोर्ट करता है।
- int
- float
- complex
Examplea = 100 # int
b = 21.8 # float
c = 12j # complex number
अगर आप type जानना चाहते है तो type() function का उपयोग कर सकते है।
a = 100 # int
b = 21.8 # float
c = 12j # complex number
print(type(a))
print(type(b))
print(type(c))
b = 21.8 # float
c = 12j # complex number
अगर आप type जानना चाहते है तो type() function का उपयोग कर सकते है।
a = 100 # int
b = 21.8 # float
c = 12j # complex number
print(type(a))
print(type(b))
print(type(c))
Python strings
string character का sequence होते है इसमें letter, numbers व special symbol उपयोग किया जा सकते है। Python में string को double quotes व single quotes दोनों में रखा जा सकता है।
Python में string bytes का array है।
string character का sequence होते है इसमें letter, numbers व special symbol उपयोग किया जा सकते है। Python में string को double quotes व single quotes दोनों में रखा जा सकता है।
Python में string bytes का array है।
Example
print("Hello World") # string in double quote
print('Hello World') # string in single quote
ऊपर दिए हुए example में देख सकते है के एक string को double quote व दूसरे string को single quote में रखा गया है दोनों उपयोग valid है python में।
print("Hello World") # string in double quote
print('Hello World') # string in single quote
ऊपर दिए हुए example में देख सकते है के एक string को double quote व दूसरे string को single quote में रखा गया है दोनों उपयोग valid है python में।
Multiline Strings
Multiline string के लिए तीन double quotes का उपयोग करना होता है python में।
a = """Hello world
How are you....."""
print(a)
Multiline string के लिए तीन double quotes का उपयोग करना होता है python में।
a = """Hello world
How are you....."""
print(a)
Access single character form stringचूँकि string character का array है इसलिए हर एक character को index का उपयोग कर access किया जा सकता है।
str_hello = "Hello world";
print(str_hello[0]);
str_hello = "Hello world";
print(str_hello[0]);
Python casting
Variable में Data के type को किसी और data type में बदलने को casting या type casting कहते है और python में ये आसानी से किया जा सकता है निम्न का उपयोग करकर।
- int()
- float()
- str()
Variable में Data के type को किसी और data type में बदलने को casting या type casting कहते है और python में ये आसानी से किया जा सकता है निम्न का उपयोग करकर।
- int()
- float()
- str()
1) int()
दिए हुए नंबर (चाहे वो whole number हो या floating number) को integer में convert करता है।
दिए हुए नंबर (चाहे वो whole number हो या floating number) को integer में convert करता है।
Example
a = int(23.4) #outputs 23
b = int('232') #outputs 232
a = int(23.4) #outputs 23
b = int('232') #outputs 232
2) float()
float() का उपयोग कर number को float में convert कर सकते है।
float() का उपयोग कर number को float में convert कर सकते है।
Example
a = float(23) #outputs 23.00
b = int('232.22') #outputs 232.22
a = float(23) #outputs 23.00
b = int('232.22') #outputs 232.22
3) str()दिए हुए नंबर float values को string में convert करने के लिए।
s - str("22.12") #outputs 22.12
t = str("hello 1234") #outputs hello 1234
s - str("22.12") #outputs 22.12
t = str("hello 1234") #outputs hello 1234
Python Scope
Variable का scope बताता है के variable को प्रोग्राम में कहाँ उपयोग किया जा सकता है इसी के आधार पर यह निम्न है।
- Local scope
- Global scope
Variable का scope बताता है के variable को प्रोग्राम में कहाँ उपयोग किया जा सकता है इसी के आधार पर यह निम्न है।
- Local scope
- Global scope
Local scope
variable को जब function के अंदर क्रिएट किया जाता है तो वह variable उसी function के अंदर उपयोग किया जा सकता है उसके बहार नहीं इसी को local scope कहते है।
def sum():
a = 300 #variable with local scope
print(a)
sum()
variable को जब function के अंदर क्रिएट किया जाता है तो वह variable उसी function के अंदर उपयोग किया जा सकता है उसके बहार नहीं इसी को local scope कहते है।
def sum():
a = 300 #variable with local scope
print(a)
sum()
Global scopeजब variable को प्रोग्राम में function के बहार क्रिएट किया जाते है और यह variables पूरे प्रोग्राम में कही भी उपयोग किये जा सकते है, ऐसे variables को Global variables कहते है।
gb = 200 #variable with global scope
def sum():
a = gb
print(a)
sum()
gb = 200 #variable with global scope
def sum():
a = gb
print(a)
sum()
Python operators
Operators का उपयोग कर variable(operands) की value को manipulate किया जा सकता है, Python में निम्न operators उपलब्ध है।
- Arithmetic operators
- Assignment operators
- Logical operators
- Comparison operators
- Identity operators
- Bitwise operators
- Membership operators
Operators का उपयोग कर variable(operands) की value को manipulate किया जा सकता है, Python में निम्न operators उपलब्ध है।
- Arithmetic operators
- Assignment operators
- Logical operators
- Comparison operators
- Identity operators
- Bitwise operators
- Membership operators
1) Arithmetic operators
+ variables में नंबर्स को जोड़ने के लिए
– variables में नंबर्स को घटाने के लिए
* variables में नंबर्स को गुणा के लिए
/ variables में नंबर्स को भाग के लिए
% variables में नंबर्स को में भाग के बाद शेष के लिए
** Exponent निकलने के लिए।
// Floor division के लिए।
| + | variables में नंबर्स को जोड़ने के लिए |
| – | variables में नंबर्स को घटाने के लिए |
| * | variables में नंबर्स को गुणा के लिए |
| / | variables में नंबर्स को भाग के लिए |
| % | variables में नंबर्स को में भाग के बाद शेष के लिए |
| ** | Exponent निकलने के लिए। |
| // | Floor division के लिए। |
2) Assignment Operators
= variable में value assign करने के लिए।
(Right hand side की value left hand side assign होती है)
+= variable की वैल्यू में right हैंड साइड की वैल्यू ऐड करता है।
x += 15 इसका मतलब x = x + 15
-= variable की वैल्यू में right हैंड साइड की वैल्यू subtract करता है।
x -= 15 इसका मतलब x = x – 15
*= variable की वैल्यू में right हैंड साइड की वैल्यू multiply करता है।
x *= 15 इसका मतलब x = x * 15
/= variable की वैल्यू को right हैंड साइड की वैल्यू से divide करता है।
x /= 15 इसका मतलब x = x / 15
%= variable की वैल्यू को right हैंड साइड की वैल्यू से divide कर
शेष(remainder) return करता है।
//= variable की वैल्यू को right हैंड साइड की वैल्यू से floor division करता है।
x //= 15 इसका मतलब x = x // 15
**= exponential calculation variable पर परफॉर्म
कर left hand side के variable में value assign करता है।
x**=20 इसका मतलब x = x ** 15
| = | variable में value assign करने के लिए। (Right hand side की value left hand side assign होती है) |
| += | variable की वैल्यू में right हैंड साइड की वैल्यू ऐड करता है। x += 15 इसका मतलब x = x + 15 |
| -= | variable की वैल्यू में right हैंड साइड की वैल्यू subtract करता है। x -= 15 इसका मतलब x = x – 15 |
| *= | variable की वैल्यू में right हैंड साइड की वैल्यू multiply करता है। x *= 15 इसका मतलब x = x * 15 |
| /= | variable की वैल्यू को right हैंड साइड की वैल्यू से divide करता है। x /= 15 इसका मतलब x = x / 15 |
| %= | variable की वैल्यू को right हैंड साइड की वैल्यू से divide कर शेष(remainder) return करता है। |
| //= | variable की वैल्यू को right हैंड साइड की वैल्यू से floor division करता है। x //= 15 इसका मतलब x = x // 15 |
| **= | exponential calculation variable पर परफॉर्म कर left hand side के variable में value assign करता है। x**=20 इसका मतलब x = x ** 15 |
3) Comparison operator
== दो operands की वैल्यू check करता है के बराबर है के नहीं
अगर बराबर है तो true return करता है नहीं तो false
!= दो operands की वैल्यू check करता है के बराबर है के नहीं
अगर बराबर नहीं है तो true return करता है नहीं तो false
<> true return करता है अगर बराबर नहीं है।
< अगर एक operand की वैल्यू दूसरे से छोटी है
तो true return करता है।
> अगर एक operand की वैल्यू दूसरे से बड़ी है तो true return करता है।
<= अगर एक operand की वैल्यू दूसरे से छोटी और बराबर है
तो true return करता है।
>= अगर एक operand की वैल्यू दूसरे से बड़ी और बराबर है
तो true return करता है।
| == | दो operands की वैल्यू check करता है के बराबर है के नहीं अगर बराबर है तो true return करता है नहीं तो false |
| != | दो operands की वैल्यू check करता है के बराबर है के नहीं अगर बराबर नहीं है तो true return करता है नहीं तो false |
| <> | true return करता है अगर बराबर नहीं है। |
| < | अगर एक operand की वैल्यू दूसरे से छोटी है तो true return करता है। |
| > | अगर एक operand की वैल्यू दूसरे से बड़ी है तो true return करता है। |
| <= | अगर एक operand की वैल्यू दूसरे से छोटी और बराबर है तो true return करता है। |
| >= | अगर एक operand की वैल्यू दूसरे से बड़ी और बराबर है तो true return करता है। |
4) Logical operators
and यह Logical AND operator है इसमें अगर दोनों statements
true है तो condition true होती है।
or यह Logical और operator है इसमें अगर दोनों statement
में से किसी एक statement true है तो condition true होती है।
not अगर इसमें operand true है तब condition False होगी।
| and | यह Logical AND operator है इसमें अगर दोनों statements true है तो condition true होती है। |
| or | यह Logical और operator है इसमें अगर दोनों statement में से किसी एक statement true है तो condition true होती है। |
| not | अगर इसमें operand true है तब condition False होगी। |
5) Identity operators
is अगर दोनों variables एक ही object है
तो यह true return करेगा।
isnot अगर दोनों variables एक ही object
के नहीं है तो यह true return करेगा।
| is | अगर दोनों variables एक ही object है तो यह true return करेगा। |
| isnot | अगर दोनों variables एक ही object के नहीं है तो यह true return करेगा। |
6) Bitwise operators
& अगर दोनों बिट 1 है तो 1 सेट करता है।
| अगर दोनों में से कोई एक बिट 1 है तो 1
सेट करता है।
^ सभी bits को 1 सेट करता अगर दोनों में से
कोई एक बिट 1 है।
~ सभी bits को उल्टा(Inverse) करता है।
मतलब सभी 0 को 1 और 1 को 0 करता है।
<< right operand में दिए हुए bits के अनुसार left operand
value को left shift करता है।
>> right operand में दिए हुए bits के अनुसार
left operand value को right shift करता है।
| & | अगर दोनों बिट 1 है तो 1 सेट करता है। |
| | | अगर दोनों में से कोई एक बिट 1 है तो 1 सेट करता है। |
| ^ | सभी bits को 1 सेट करता अगर दोनों में से कोई एक बिट 1 है। |
| ~ | सभी bits को उल्टा(Inverse) करता है। मतलब सभी 0 को 1 और 1 को 0 करता है। |
| << | right operand में दिए हुए bits के अनुसार left operand value को left shift करता है। |
| >> | right operand में दिए हुए bits के अनुसार left operand value को right shift करता है। |
7) Membership operators
in दिए हुए sequence में दी हुई value
present है तो true return करता है।
not in दिए हुए sequence में दी हुई value
present नहीं है तो true return करता
| in | दिए हुए sequence में दी हुई value present है तो true return करता है। |
| not in | दिए हुए sequence में दी हुई value present नहीं है तो true return करता |

0 Comments