Python Programming Hub https://www.pyprohub.com Python and Python related tutorials like DSA with Python, Artificial Intelligence, Machine learning, Data Analytics, etc. Thu, 05 Jun 2025 10:09:14 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.1 https://www.pyprohub.com/wp-content/uploads/2025/05/cropped-python-programming-hub-main-logo-32x32.jpg Python Programming Hub https://www.pyprohub.com 32 32 Python List https://www.pyprohub.com/python-list-in-hindi https://www.pyprohub.com/python-list-in-hindi#respond Thu, 24 Apr 2025 14:37:02 +0000 https://www.pyprohub.com/?p=2903
Edit Template
Edit Template
Edit Template

Python List in Hindi

What is Python List in hindi (python me list kya hota hai)

Python List in hindi : python में list बनाने के लिए हम square bracket का use करते हैं, और उनके अंदर values को comma से  separate करके Store करते हैं. जैसा की example में दिया गया है

number_list = [5, 48, 9, 789, 0, 45]
string_list = ["mango", "banana", "apple"]
mixed_list = ["apple", 56, True, 2.8]
empty_list = []

print(number_list)
print(string_list)
print(mixed_list)
print(empty_list)

# output:
# [5, 48, 9, 789, 0, 45]
# ['mango', 'banana', 'apple']
# ['apple', 56, True, 2.8]
# []

What is Nested List in python in hindi (python me nested list kya hai)

अगर हम list केअंदर list बनाते हैं तो इसे nested list कहा जाएगा. for Example

nested_list = [[5,8],[4,1],[2,8]]
print(nested_list)
# Output:
# [[5,8],[4,1],[2,8]]

what is range list in python in hindi (python me range list kya hai)

python मे range() एक method होता है, जिसके help से हम python List को create कर सकते है। जो list range() method के help से create किया जाता है उन्हे range list कहा जाता है।

num = list(range(1, 10))
print(num)
# Output:
# [1, 2, 3, 4, 5, 6, 7, 8, 9]

what is list comprehension in python in hindi (python me list comprehention kya hai)

pythhon मे list comprehension एक तरीका है list create करने का 

comprehension_list = [a**2 for a in range(1, 6)]
print(comprehension_list)
# Output:
# [1, 4, 9, 16, 25]

what is list indexing in python in hindi or how to access list items (python me list indexing kya hai)

अगर हम python list मे से किसी particular item को access करना चाहते है तो indexing का use करते है। indexing positive और negative दोनों तरीके से की जा सकती है। positive indexing मे list के first item को access करने के लिए “0” का use करते है और negative indexing मे list के last item को access करने के लिए “-1” का use  करते है।

my_list = ["banana", "grapes", "apple"]
print(my_list[0])
print(my_list[-1])
# Output:
# banana
# apple

how to change list items in python in hindi (python me list ke items ko change kaise kare)

python मे हम list के items को direct assignment के through change कर सकते है। list के जिस भी item को change करना उसे indexing के through select किया जाता है। 

my_list = ["banana", "grapes", "apple"]
my_list[1] = "orange"
print(my_list)
# Output:
# ['banana', 'orange', 'apple']

how to iterate list items in python in hindi (python me list ke items ko iterate kaise kare)

python मे हम list के items को for loop के through iterate कर सकते है। 

my_list = ["banana", "grapes", "apple"]
for i in my_list:
    print(my_list)
# Output:
# ['banana', 'grapes', 'apple']

how to add lists in python in hindi (python me lists ko add kaise kare)

python मे हम “+” operator का use करके lists को आसानी से add  कर सकते है।

list1 = ["banana", "grapes", "apple"]
list2 = [1, 2, 3]
# Output:
# ['banana', 'grapes', 'apple', 1, 2, 3]

List Methods

python मे list के लिए कई सारे build-in methods होते है.

Syntex:

method को किसी भी variable के साथ use करने के लिए dot ( . ) का use करते है।

Example:

append() : इस method का use करके हम string के सभी lower case letters को upper case मे कर सकते है। 

list1 = ["banana", "grapes", "apple"]
list1.append("orange")
print(list1)
# Output:
# ['banana', 'grapes', 'apple', 'orange']

यहाँ कुछ list के methods दिए गए है जिन्हे आप इसी तरह से list के साथ use करके इनके result को देख सकते है।

append(): नए element को list के end मे add करता है। 

insert(): नए element को specified index पर insert करता है।

remove(): किसी Specified value को list मे से remove करता है।

pop(): किसी Specified index परर element को remove करता है।

index(): किसी Specified value का first occurrence का index return करता है। 

count(): किस Specified value का occurrences count करता है।

sort(): List के elements को sort करता है।

reverse(): List के elements को reverse करता है।

# Ek empty list banate hain
my_list = []

# 1. append() - End me elements add karte hain
my_list.append(10)
my_list.append(20)
my_list.append(30)
print("After append:", my_list)  # [10, 20, 30]

# 2. insert() - Specific index par element insert karte hain
my_list.insert(1, 15)  # Index 1 par 15 insert hoga
print("After insert:", my_list)  # [10, 15, 20, 30]

# 3. remove() - Specific value ko remove karte hain
my_list.remove(20)
print("After remove:", my_list)  # [10, 15, 30]

# 4. pop() - Specific index se element remove aur return karte hain
removed_element = my_list.pop(1)  # Index 1 ka element hataenge
print("Popped element:", removed_element)  # 15
print("After pop:", my_list)  # [10, 30]

# 5. index() - Kisi value ka first index find karte hain
index_of_30 = my_list.index(30)
print("Index of 30:", index_of_30)  # 1

# 6. count() - Kisi value ka count nikalte hain
count_of_10 = my_list.count(10)
print("Count of 10:", count_of_10)  # 1

# 7. sort() - List ko ascending order me sort karte hain
my_list.append(5)
my_list.append(25)
print("Before sort:", my_list)  # [10, 30, 5, 25]
my_list.sort()
print("After sort:", my_list)  # [5, 10, 25, 30]

# 8. reverse() - List ko reverse karte hain
my_list.reverse()
print("After reverse:", my_list)  # [30, 25, 10, 5]

उम्मीद करते है कि आपको python list अच्छे समझ मे आ गया होगा । अपने learning को continue रखने के लिए next button पर click करे,

Add a comment...

Your email address will not be published. Required fields are marked *

  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
Python List

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python String

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Loops

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Conditional Statements

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Operators

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Data Type

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Scikit-learn

Scikit-learn Tutorial Scikit-learn Hamburger Toggle Menu Edit Template Scikit learn in Hindi What is Scikit-learn in Hindi Scikit learn एक...

Pandas

Pandas Tutorial Pandas Hamburger Toggle Menu Edit Template Pandas in Hindi What is Pandas in Hindi pandas  एक python library...

NumPy

NumPy Tutorial NumPy Hamburger Toggle Menu Edit Template NumPy in Hindi What is NumPy in Hindi matplotlib का use हम...

Edit Template
]]>
https://www.pyprohub.com/python-list-in-hindi/feed 0
Python String https://www.pyprohub.com/python-string-hindi https://www.pyprohub.com/python-string-hindi#respond Tue, 22 Apr 2025 13:51:05 +0000 https://www.pyprohub.com/?p=2876
Edit Template
Edit Template
Edit Template

Python String

What is Python String

Python String : Single and double quote के अंदर हम कुछ लिखते हैं तो यह string कहलाता है.

Triple quote के अंदर हम कुछ लिखते हैं तो भी यह string कहलाता है इसका use हम multi line string के लिए करते हैं.

print("this is single line string")
print("""this is
multi-line
string""")

String Indexing

अगर हम string में से किसी specific data को print करना चाहते हैं तो indexing का use करते हैं.

 python string में characters का indexing 0 से start होता है, और negative indexing end से start होता है  -1 last character को represent करता है.

text = "hello, world!"
print(text[0])
print(text[-1])
#output
#   h
#   !

String Slicing

slicing का use string के Sab string पाने के लिए होता है,

start: Ye wo index hai jahan se slicing start hoti hai.

stop: Ye wo index hai jahan tak slicing hoti hai.

step: Ye optional parameter hai jo batata hai ki kitne steps ka difference rakhna hai.

Agar aap start, stop, ya step ko nahi dete, to default values use hoti hain:

Default value for start is 0.

Default value for stop is length of the string.

Default value for step is 1

text = "hello, world!"
print(text[0:5])
print(text[7:])
print(text[:5])
print(text[-6:-1])
print(text[0:5:2])
#output
# hello
# world!
# hello
# world
# hlo

String Concatenation

string concatenation का मतलब होता है एक या एक से अधिक strings को add करके single string मे convert करना। 

string को concatenate करने के लिए + operator या join methode का use किया जाता है।

a = "python"
b = "programing"
c = "hub"

# using + operator
print(a +" "+ b +" "+ c)

# using join methode
print(" ".join([a,b,c]))

# output
# python programing hub
# python programing hub

NOTE: string concatenation मे हमने double quote ( ” ” ) का use इसलिए किया है ताकि हम strings के बीच मे space दे सके अगर double quote नहीं लगाएंगे तो सारे strings एक मे mix होकर single word बन जाएंगे। 

अगर आप double quote के अंदर कुछ लिखेंगे तो वो भी string मे join हो जाएगा।

String Formatting

अगर हम चाहते है कि string मे variables या expressions के value को direct insert कर सके तो हमे string formatting का उसे करना होगा। python मे string formatting बनाने के लिए % operator, str.format() method और f-strings का use करते है। 

% Operator

name = "Lisa"
age = 25
print("Hello my name is %s and I am %d year old." %(name, age))

str.format Method

name = "Lisa"
age = 25
print("My name is {} and I am {} years old.".format(name, age))
# Output: My name is Lisa and I am 25 years old.

f-strings

name = "Lisa"
age = 25
print(f"My name is {name} and I am {age} years old.")
# Output: My name is Charlie and I am 35 years old.

# Aap expressions bhi use kar sakte hain
print(f"Next year, I will be {age + 1} years old.")
# Output: Next year, I will be 26 years old.

String Methods

python मे string के लिए कई सारे build-in methods होते है जिन्हे use करने पर string अलग अलग तरीके से perform करता है।

Syntex:

method को किसी भी variable के साथ use करने के लिए dot ( . ) का use करते है।

Example:

str.upper() : इस method का use करके हम string के सभी lower case letters को upper case मे कर सकते है। 

text = "hello"
result = text.upper()
print(result)  
# Output: HELLO

यहाँ कुछ methods दिए गए है जिन्हे आप इसी तरह से string के साथ use करके इनके result को देख सकते है। आपको str के जागह अपने string या string variable को use करना है।

MethodDescription
str.upper()String ko uppercase me convert karta hai
str.lower()String ko lowercase me convert karta hai
str.capitalize()Pehla letter uppercase karta hai, baaki lowercase
str.title()Har word ka pehla letter uppercase karta hai
str.strip()Start aur end ke whitespace (ya characters) remove karta hai
str.lstrip()Left se whitespace (ya characters) hatata hai
str.rstrip()Right se whitespace (ya characters) hatata hai
str.replace(old, new)String me kisi substring ko replace karta hai
str.split(separator)String ko list me todta hai
str.join(iterable)List (ya iterable) ko string me jodta hai
str.find(sub)Substring ka index return karta hai (nahi mila to -1)
str.index(sub)Substring ka index deta hai (error deta hai agar na mile)
str.count(sub)Substring kitni baar aaya hai, wo count karta hai
str.startswith(prefix)Check karta hai ki string kisi prefix se start ho rahi hai ya nahi
str.endswith(suffix)Check karta hai ki string kisi suffix se end ho rahi hai ya nahi
str.isalpha()Check karta hai ki sab characters alphabets hain ya nahi
str.isdigit()Check karta hai ki sab characters digits hain ya nahi
str.isalnum()Alphabets + Digits hain to True return karta hai
str.isspace()Agar string me sirf whitespace ho to True
str.islower()Check karta hai ki string lowercase me hai ya nahi
str.isupper()Check karta hai ki string uppercase me hai ya nahi
str.swapcase()Uppercase ko lowercase aur vice versa karta hai
str.zfill(width)String ke left me 0 add karta hai given width tak
str.center(width)String ko center me rakhkar padding deta hai
str.ljust(width)Left justify karta hai
str.rjust(width)Right justify karta hai
str.partition(sep)String ko 3 parts me todta hai (before, sep, after)
str.rpartition(sep)Rightmost separator se partition karta hai

उम्मीद करते है कि आपको python operators अच्छे समझ मे आ गया होगा । अपने learning को continue रखने के लिए next button पर click करे,

Some important questions in this tutorial

What is Python String, Python me String kya hota hai.

Add a comment...

Your email address will not be published. Required fields are marked *

  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
Python List

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python String

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Loops

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Conditional Statements

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Operators

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Data Type

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Scikit-learn

Scikit-learn Tutorial Scikit-learn Hamburger Toggle Menu Edit Template Scikit learn in Hindi What is Scikit-learn in Hindi Scikit learn एक...

Pandas

Pandas Tutorial Pandas Hamburger Toggle Menu Edit Template Pandas in Hindi What is Pandas in Hindi pandas  एक python library...

NumPy

NumPy Tutorial NumPy Hamburger Toggle Menu Edit Template NumPy in Hindi What is NumPy in Hindi matplotlib का use हम...

Edit Template
]]>
https://www.pyprohub.com/python-string-hindi/feed 0
Python Loops https://www.pyprohub.com/loops-in-python-in-hindi https://www.pyprohub.com/loops-in-python-in-hindi#comments Tue, 04 Mar 2025 07:20:06 +0000 https://pyprohub.com/?p=2242
Edit Template
Edit Template
Edit Template

Loops in Python in hindi

What is Loops in Python in hindi

python मे अगर हमे किसी block of code को बार बार चलाना होता है तो हम loops का use करते है। python मे 2 types के loop होते है-

1. For Loop 

2. While Loop 

What is While Loop

Python में जब हमें किसी block को Repeatedly execute करना होता है तो हम while loop का use करते हैं  while loop एक control flow statement है यह किसी block को तब तक execute करता है जब तक condition true होती है

How While Loop Work

while loop start होने से पहले Condition को Check करता है अगर Condition true होती है तो loop के अंदर का Code execute होता है एक बार execution होने के बाद block के अंदर condition update होता है और Condition true होता है तो code का execution फिर से होता है और यह प्रक्रिया तब तक चलता रहता है जब तक Condition False ना हो जाए. इसलिए हमें Condition को सावधानीपूर्वक देना होता है वरना loop infinite हो जाएगा और code का Execution कभी रुकेगा ही नहीं

example से समझते हैं

num = 1  # Initialization
while num <= 5:  # Condition
    print(num)
    num += 1  # Increment

Nested While Loop

जब हम while loop के अंदर while loop को used करते हैं तो इसे nested while loop बोला जाता है चलिए इस एक example के through समझते हैं

i = 1
while i <= 3:  # Outer loop (Rows)
    j = 1
    while j <= 3:  # Inner loop (Columns)
        print("*", end=" ")  # Print star in the same row
        j += 1
    print()  # Move to the next line
    i += 1

What is For Loop

for loop एक control flow statement है इसका use हम generally sequence (जैसे –  list, set, string, etc.) के Elements पर perform करने के लिए करते हैंFor loop elements को sequence से एक-एक करके retrieve करता है 

Example के through समझते हैं

fruits = ["apple", "banana", "cherry"]

for fruit in fruits:
    print(fruit)

What is Range Function

range एक function है जिसका  use numeric sequence generate करने के लिए होता है यह function एक  sequence के number को  return करता है जो का  look में  I treat किया जा सकता है

How Range Function Work

 Start : यह Range की  starting value होती है जो  by default 0 होता है मतलब अगर हमने range में  starting value नहीं दिया है तो  for loop by default इस  value को 0 मानेगा but अगर हमने कोई value दिया है तो और loop वहीं से शुरू होगा

 Stop : यह ending value होती है हम range में stop की value जितनी रखेंगे और look उतना बार code को Execute करेगा

 Step :  यह increment value होती है जो red fault 1 रहता है मतलब हम range में increment value ना देतो इसका By default 1 एक माना जाएगा मतलबHot का  execution एक-एक  step में करेगा

 example के through समझते हैं

for num in range(1, 10, 2):  # Step = 2
    print(num)

Nested For Loop

अगर हम For loop के अंदर भी for loop का use करते हैं तो इसे nested for loop बोला जाता है

Example से समझते हैं

for i in range(3):  # Outer loop (rows)
    for j in range(3):  # Inner loop (columns)
        print("*", end=" ")  # Print in same line
    print()  # Move to next line

What is Break Statement

अगर हमें Loop को Permanently terminate करना होता है तो हम Break का use करते हैं, लिए break को अच्छे से समझने के लिए एक example देखते हैं

for num in range(1, 6):
    if num == 3:
        break  # Stops when num = 3
    print(num)

What is Continue Statement

अगर हम look में current Iteration को  skip करके next iteration पर jump करना चाहते हैं तो continue statement का use करते हैं

 example के  through अच्छे से समझते हैं

for num in range(1, 6):
    if num == 3:
        continue  # Skips 3
    print(num)

उम्मीद करते है कि आपको loops in python अच्छे समझ मे आ गया होगा । अपने learning को continue रखने के लिए next button पर click करे,

Some important questions in this tutorial

What is loops in python, Python me loops kya hota hai.

1 Comment

  • vishal

    nice explanation

Add a comment...

Your email address will not be published. Required fields are marked *

  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
Python List

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python String

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Loops

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Conditional Statements

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Operators

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Data Type

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Scikit-learn

Scikit-learn Tutorial Scikit-learn Hamburger Toggle Menu Edit Template Scikit learn in Hindi What is Scikit-learn in Hindi Scikit learn एक...

Pandas

Pandas Tutorial Pandas Hamburger Toggle Menu Edit Template Pandas in Hindi What is Pandas in Hindi pandas  एक python library...

NumPy

NumPy Tutorial NumPy Hamburger Toggle Menu Edit Template NumPy in Hindi What is NumPy in Hindi matplotlib का use हम...

Edit Template
]]>
https://www.pyprohub.com/loops-in-python-in-hindi/feed 1
Conditional Statements https://www.pyprohub.com/conditional-statements-in-python-in-hindi https://www.pyprohub.com/conditional-statements-in-python-in-hindi#respond Thu, 27 Feb 2025 07:07:11 +0000 https://pyprohub.com/?p=2224
Edit Template
Edit Template
Edit Template

Conditional Statements in Python in Hindi

What is Conditional Statements in python in Hindi

python में  decision making के लिए If-else conditional statement का use करते हैं, यह  specific conditions के  basis पर  code के different block को execute करते हैं, if-else का use करके हम program के flow को dynamically control कर सकते हैं.

How if-else work

If Statement

यह condition को check करता है अगर condition true हुई तो if block execute हो जाता है अगर condition true नहीं हुई तो if block का execution नहीं होता है

num = 10

if num > 5:
    print("Number is greater than 5")
else:
    print("Number is 5 or less")
    
# Output: Number is greater than 5

Else Statement

अगर if condition false होती है तो else block का execution होता है.

इसे एक Example se समझते हैं

num = 5

if num > 5:
    print("Number is greater than 5")
else:
    print("Number is 5 or less")
    
# Output: Number is  5 or less

Elif Statement

python में multiple condition को  check करने के लिए elif statement का  use करते हैं जब एक से ज्यादा  conditions को sequencely check करना होता है तो इसका use किया जाता है

How elif works : 

इसका  use  if and else के बीच में किया जाता है हम अपने जरूरत के हिसाब से  multiple elif का Use करते हैं अगर if condition false हो जाती है तो  elif block का execution होता है अगर हमने अपने program में एक से ज्यादा elif का use किया है तो जो condition सही होगा उस elif block का execution होगा

इसे एक example के through समझते हैं : 

marks = 75

if marks >= 90:
    print("Grade: A")
elif marks >= 75:
    print("Grade: B")
elif marks >= 50:
    print("Grade: C")
else:
    print("Grade: F")

# Output: Grade: B

Nested if-else

जब हम किसी if condition के अंदर भी कोई condition check  Karte Hain तो इसे nested if else  कहते हैं

age = 20
has_id = True

if age >= 18:
    if has_id:
        print("You can vote")
    else:
        print("You need an ID to vote")
else:
    print("You are too young to vote")

# Output: You can vote

Ternary Operator

अगर python में हम conditional expression को एक लाइन में लिखने चाहे तो Ternary operator का use करना होता है इसमें value और condition और statement एक ही लाइन में लिख सकते हैं जैसा की syntax में दिया गया है

आइए इसे एक example की  help समझते हैं

num = 10
result = "Even" if num % 2 == 0 else "Odd"
print(result)

# Output: Even

उम्मीद करते है कि आपको conditional statements in python अच्छे समझ मे आ गया होगा । अपने learning को continue रखने के लिए next button पर click करे,

Some important questions in this tutorial

What is Conditional Statements in Python, Python me Conditional Statements kya hota hai.

Click here www.w3schools.com/python  to learn python in english

Add a comment...

Your email address will not be published. Required fields are marked *

  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
Python List

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python String

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Loops

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Conditional Statements

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Operators

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Data Type

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Scikit-learn

Scikit-learn Tutorial Scikit-learn Hamburger Toggle Menu Edit Template Scikit learn in Hindi What is Scikit-learn in Hindi Scikit learn एक...

Pandas

Pandas Tutorial Pandas Hamburger Toggle Menu Edit Template Pandas in Hindi What is Pandas in Hindi pandas  एक python library...

NumPy

NumPy Tutorial NumPy Hamburger Toggle Menu Edit Template NumPy in Hindi What is NumPy in Hindi matplotlib का use हम...

Edit Template
]]>
https://www.pyprohub.com/conditional-statements-in-python-in-hindi/feed 0
Python Operators https://www.pyprohub.com/python-operators-in-hindi https://www.pyprohub.com/python-operators-in-hindi#respond Wed, 26 Feb 2025 07:12:28 +0000 https://pyprohub.com/?p=2211
Edit Template
Edit Template
Edit Template

Python Operators in Hindi

What is Python Operators in Hindi

Python Operators : python में operators का use कई सारे operations perform करने के लिए किया जाता है, जैसे arithmetic operations, comparison operations, logical operations, assignment operations, membership operations, identity operations, bitwise operations, etc.

Types of Operators in Python

Arithmetic Operators

Arithmetic operators का use mathematical operations को perform करने के लिए होता है

+ (addition) : numbers को add करने के लिए इस operator का use करते हैं

–  (subtraction) : numbers को subtract करने के लिए इस operator का use करते हैं

* (multiplication) : numbers को multiple करने के लिए operator का use करते हैं 

/ (division) : 2 numbers का division decimal points के साथ जानने के लिए इस operator का use करते हैं

% (modulus) : 2 numbers के division का remainder जानने के लिए इस operator का use करते हैं

// (floor division) : 2 numbers का division decimal points में जानने के लिए इस operator का use करते हैं 

** (exponentiation)  किसी number का power निकालने के लिए इस operator के use करते हैं

# Take input from the user
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

# Perform arithmetic operations
addition = num1 + num2
subtraction = num1 - num2
multiplication = num1 * num2
division = num1 / num2  # Regular division
floor_division = num1 // num2  # Floor division
modulus = num1 % num2  # Remainder
exponentiation = num1 ** num2  # Power

# Display results
print(addition)
print(subtraction)
print(multiplication)
print(division)
print(floor_division)
print(modulus)
print(exponentiation)

Comparison Operators

जब हमें values को compare करना होता है तो हम comparison operators का use करते हैं, यह values को compare करके true या false return करता है.

Equal to Operator ( == ) : अगर हमें यह check करना हो की values समान है कि नहीं तो हम equal to operator का use करते हैं, अगर values एक समान हुआ तो true return करेगा अगर different हुआ तो false

Not Equal to Operator ( != ) : अगर हमें values check करना हो कि यह different है कि नहीं तो not equal to operator का use करते हैं, अगर values different हुई तो true return करेगा अगर equal हुआ तो false

Less than Operator ( < ) : 1st value 2nd value se छोटी है कि नहीं यह check करने के लिए less than operator का use करना होता है अगर 1st value छोटी हुई तो true return करेगा otherwise false

Greater than Operator ( > ) : 1st value 2nd value se बड़ी है कि नहीं यह check करने के लिए greater than operator का use करते हैं अगर वह बड़ी हुई तो true return करेगा otherwise false

Less than or Equal to Operator ( <= ) : 1st value 2nd value के बराबर या फिर छोटी है यह check करने के लिए  less than or equal to operator का use करते हैं अगर 1st value 2nd value से छोटी हुई या उसके equal हुई तो यह true return करेगा otherwise false

Greater than or Equal to Operator ( >= ) : 1st value 2nd value से बड़ी या उसके बराबर है कि नहीं यह check करने के लिए greater than or equal to operator का use करते हैं अगर 1st value 2nd value से पड़ी हुई या उसके बराबर हुई तो यह true return करेगा otherwise false

print(10 > 5)
print(3 < 1)
print(7 == 7)
print(8 != 6)
print(4 >= 4)
print(2 <= 1)

Logical Operators

Logical operators का use boolean values (true and false) ya conditional statements को combine करने के लिए होता है

AND Operator : यह statements को check करता है अगर सारे statement true हो तो true return करता है otherwise false return करेगा

OR Operator : यह statement को check करता है अगर कोई भी एक statement true हुआ तो return करेगा otherwise false return करेगा

NOT Operator :  यह statement को check करता है और statement true हुआ तो false return करेगा अगर statement false हुआ तो true return करेगा

print(5 > 3 and 10 < 20)
print(7 < 2 or 6 == 6)
print(not (4 == 4))

Membership Operators

Membership operator का use sequential data type (जैसे – list, tuple, string etc.) में specified value की existence को check करने के लिए होता है, ye 2 type ke hote hai.

In :  अगर sequence में specified value होगी true return करेगा otherwise false return करेगा

Not in : अगर sequence में specific value नहीं होगी तो true return करेगा otherwise false return करेगा

fruits = ["apple", "banana", "cherry"]
print("banana" in fruits)  # Output: True
print("banana" not in fruits)  # Output: False

Identical Operators

यह  operator Values को नहीं बल्कि  Objects के Memory location को  compare करता है

is :  variables को  check करता है और अगर दोनों  variables same object को  refer करते हैं तो  true return करेगा Otherwise false return करेगा

is not : यह  variables को  check करता हैअगर दोनों Variables same object को  refer नहीं करते तो  true return करेगा Otherwise false return करेगा

a = 10
b = 10
print(a is b)  # Output: True
print(a is not b)  # Output: False

Bitwise Operators

यह  operator integer के  binary representation में  operation perform करता है

जैसा कि हम जानते हैं  computer कोई भी Data को bits में  Store करता है यानी की 0 aur 1 के form में इसीलिए जितने भी numbers होते हैं उनका binary representation होता है जैसे 1 का 001, 2 का 10, 3 का 011 तो Bitwise operator in ही Binary number के बीच  work करता है

& (and bitwise) : यह  bitwise operator दो  values के  binary representation में  perform करता है और दोनों  bit 1 हुए तो 1  दे resultता है  otherwise 0 result देता है

| (Or bitwise) : दो  values के  binary  representation में   perform करते हैं और अगर अगर दोनों में से कोई भी   bit 1 है तो  result 1 देगा,  otherwise 0 देगा

^ (Xor bitwise) :  xor Operator भी दो  Values के  binary representation में Perform करता है अगर दोनों  bit same  है तो 0  result देगा   but एक 0 और एक 1 है मतलब दोनों bit different है तो एक  result देगा

~ (Not bitwise) : Not  bitwise operator किसी  values के  binary representation को opposite कर देता है अगर 0 है तो 1 में बदल देगा और 1 है तो 0 में बदल देगा

<< (Left Shift bitwise) :  left  Shift bitwise operator किसी  value के bit  को  left side main shift कर देता है और खाली स्थान को 0 से भर देता है

>> (Right Shift bitwise) :  right shift Bitwise operatorकिसी  value के  bit को  right side की ओर shift कर देता है ,अगर  value positive होती है तो  shifting के बाद खाली स्थान को 0 से भरा data है, यदि  value negative होती है तो खाली  shifting के बाद खाली स्थान को 1 से भरा data है

a = 5  # 5 in binary:  0101
b = 3  # 3 in binary:  0011
print(a & b)  # Output: 1 (0001)
print(a | b)  # Output: 7 (0111)
print(a ^ b)  # Output: 6 (0110)
print(~a)  # Output: -6 (In two’s complement form)
print(a << 1)  # Output: 10 (1010)
print(a >> 1)  # Output: 2 (0010)

Assignment Operators

assignment operator का  use values को  assign करने के लिए होता है

= Assign Operator : किसी  variable में कोई  value assign करने के लिए  assign value operator का   use करते हैं

आई बाकी बचे  assignment operators कोअ च्छे से समझने के लिए table को देखते हैं 

a = 10
print(a)  # Output: 10

उम्मीद करते है कि आपको python operators अच्छे समझ मे आ गया होगा । अपने learning को continue रखने के लिए next button पर click करे,

Some important questions in this tutorial

What is Python Operators, Python me Operators kya hota hai.

Add a comment...

Your email address will not be published. Required fields are marked *

  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
Python List

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python String

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Loops

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Conditional Statements

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Operators

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Data Type

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Scikit-learn

Scikit-learn Tutorial Scikit-learn Hamburger Toggle Menu Edit Template Scikit learn in Hindi What is Scikit-learn in Hindi Scikit learn एक...

Pandas

Pandas Tutorial Pandas Hamburger Toggle Menu Edit Template Pandas in Hindi What is Pandas in Hindi pandas  एक python library...

NumPy

NumPy Tutorial NumPy Hamburger Toggle Menu Edit Template NumPy in Hindi What is NumPy in Hindi matplotlib का use हम...

Edit Template
]]>
https://www.pyprohub.com/python-operators-in-hindi/feed 0
Python Data Type https://www.pyprohub.com/python-data-type-and-casting-function https://www.pyprohub.com/python-data-type-and-casting-function#respond Tue, 25 Feb 2025 08:21:37 +0000 https://pyprohub.com/?p=2195
Edit Template
Edit Template
Edit Template

Python Data Type

What is Python Data Type

Python Data Type : variable  में हम जब भी कोई data store करते हैं तो उसका एक type होता है, python में कई तरह के data type होते हैं जैसे : numeric, sequence, set, etc.  लिए इनके बारे में अच्छे से समझते हैं।

आसान भाषा मे कहे तो data type हमे बताता है की variable मे हम कैसी information को store कर रहे है क्या वो number है, text है या कुछ और।

Types of Data Type in Python

python मे अलग अलग types के information को store करने के लिए अलग अलग types के data type होते है। जैसे : – 

1.  Numeric data type : Numeric data type numbers को represent करता है जैसे: 1, -1, 1.5 जितने भी numbers होते हैं इन्हें numeric data type कहा जाता है। 

python में numeric data type तीन तरह के होते हैं. Integers, floating-point numbers, complex numbers. 

  • integers वह सभी numbers होते हैं जो बिना decimal point के होते हैं, यह positive, negative या zero हो सकते हैं जैसे : 1, -4, 0.
  • Floating point numbers वह numbers होते हैं जो decimal point के साथ होते हैं, जैसे : 3.15, – 1.2, 0.0 etc.
  • Complex numbers वह numbers होते हैं जो real और imaginary port को combine करते हैं,  जैसे : 1+3j, 2-5j, etc.

 

2.  Sequence data type : Sequence data type, text  represent करता है जैसे: string, list, tuple इनके बारे में अब आगे अच्छे से समझेंगे। 

Single and double quote के अंदर हम कुछ लिखते हैं तो यह string कहलाता है। 

Triple quote के अंदर हम कुछ लिखते हैं तो भी यह string कहलाता है इसका use हम multi line string के लिए करते हैं।

3.  Mapping type : Mapping type जैसे की dict यह key value pairs का unordered collection होता है, इसके uses को आगे समझेंगे। 

4.  Set type : Set type, set unique items का unordered collection होता है आपने math में set तो पढ़ा ही होगा कुछ इसी type का यह भी होता है इसके बारे में अब आगे समझेंगे। 

5.  Boolean type : Boolean type, true ओर false को represent करता है।

6. None type : None type हम जब भी कोई variable बनाते हैं और अगर उसमें कोई value ना दे तो उसमें एक rough value आ जाती है, but हम चाहते इसमें कोई value ना हो तो इसमें none को assign कर देते हैं। 

# Numeric Data Types
integer_value = 10   # int
float_value = 20.5   # float
complex_value = 3 + 4j  # complex

# Text Data Type
string_value = "Hello, Python!"  # str

# Sequence Data Types
list_value = [1, 2, 3, 4, 5]  # list (mutable)
tuple_value = (10, 20, 30)  # tuple (immutable)

# Set Data Types
set_value = {1, 2, 3, 4, 5}  # set (unordered, unique values)
frozenset_value = frozenset({10, 20, 30})  # frozenset (immutable set)

# Mapping Data Type
dict_value = {"name": "Alice", "age": 25}  # dictionary (key-value pairs)

# Boolean Data Type
bool_value = True  # bool (True or False)

# Displaying types
print(integer_value)
print(float_value)
print(complex_value)
print(string_value)
print(list_value)
print(tuple_value)
print(set_value)
print(frozenset_value)
print(dict_value)
print(bool_value)

What is Casting Function

किसी data के data type को किसी और data type में convert करने के लिए इस method का use करते हैं

Int :  जब हम किसी value को integer में convert करते हैं तो ‘int’ का use करते हैं। 

# Convert float and string to integer
float_num = 10.9
string_num = "25"

print(int(float_num))  # Output: 10 (Decimal part is removed)
print(int(string_num))  # Output: 25 (String is converted to int)

Float :  जब हम किसी value को floating point number में convert करते हैं तो ‘float’ का use करते हैं

# Convert int and string to float
int_num = 10
string_float = "15.75"

print(float(int_num))  # Output: 10.0
print(float(string_float))  # Output: 15.75

Complex : जब हम किसी value को complex number में convert करते हैं तो ‘complex’ का use करते हैं.

# Convert int and float to complex
int_num = 5
float_num = 2.3

print(complex(int_num))  # Output: (5+0j)
print(complex(float_num))  # Output: (2.3+0j)

# Convert two numbers into a complex number (real + imaginary)
print(complex(3, 4))  # Output: (3+4j)

String : जब हम किसी value को string में convert करते हैं तो ‘str’ का use करते हैं

# Convert int, float, and complex to string
int_value = 100
float_value = 25.6
complex_value = 3 + 5j

print(str(int_value))  # Output: "100"
print(str(float_value))  # Output: "25.6"
print(str(complex_value))  # Output: "(3+5j)"

उम्मीद करते है कि आपको python data type अच्छे समझ मे आ गया होगा । अपने learning को continue रखने के लिए next button पर click करे,

Some important questions in this tutorial

What is Python Data Type, python me data type kya hota hai.

Add a comment...

Your email address will not be published. Required fields are marked *

  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
Python List

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python String

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Loops

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Conditional Statements

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Operators

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Data Type

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Scikit-learn

Scikit-learn Tutorial Scikit-learn Hamburger Toggle Menu Edit Template Scikit learn in Hindi What is Scikit-learn in Hindi Scikit learn एक...

Pandas

Pandas Tutorial Pandas Hamburger Toggle Menu Edit Template Pandas in Hindi What is Pandas in Hindi pandas  एक python library...

NumPy

NumPy Tutorial NumPy Hamburger Toggle Menu Edit Template NumPy in Hindi What is NumPy in Hindi matplotlib का use हम...

Edit Template
]]>
https://www.pyprohub.com/python-data-type-and-casting-function/feed 0
Digital Fundamentals Exercise https://www.pyprohub.com/digital-fundamentals-exercise Wed, 12 Feb 2025 08:59:23 +0000 https://pyprohub.com/?p=817
Edit Template
Edit Template
Edit Template

Digital Fundamentals Exercise

Find the output of the following logic circuit if A = 1 and B = 0. The circuit consists of an AND gate followed by a NOT gate.
  • AND gate output: 1⋅0=01 \cdot 0 = 0
  • NOT gate output: 0‾=1\overline{0} = 1
  1. Divide the number by 2 and record the remainder:
    • 29 ÷ 2 = 14, remainder 1
    • 14 ÷ 2 = 7, remainder 0
    • 7 ÷ 2 = 3, remainder 1
    • 3 ÷ 2 = 1, remainder 1
    • 1 ÷ 2 = 0, remainder 1

Binary: 11101

Answer: 13 in decimal

Using the Distributive Law:

A⋅(B+B′)=A⋅1=AA \cdot (B + B’) = A \cdot 1 = A

The select lines (S1, S0) = (1, 0) select I2 as the output.
I2 = 0

Answer: 0

  1. Binary sum: 0101 + 0110 = 1011 (invalid BCD)
  2. Add 0110 (6) for BCD correction:
    1011 + 0110 = 0001 0001

Answer: 0001 0001 (11 in BCD)

This is a D Flip-Flop, where the next state simply follows the input.

  1. Invert the digits: 1101 → 0010
  2. Add 1: 0010 + 1 = 0011

Answer: 0011

ABSumCarry
0000
0110
1010
1101
A\B01
001
110

The simplified Boolean expression is:

f(A,B)=A⊕Bf(A, B) = A \oplus B

Answer: A XOR B

  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
Python List

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python String

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Loops

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Conditional Statements

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Operators

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Data Type

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Scikit-learn

Scikit-learn Tutorial Scikit-learn Hamburger Toggle Menu Edit Template Scikit learn in Hindi What is Scikit-learn in Hindi Scikit learn एक...

Pandas

Pandas Tutorial Pandas Hamburger Toggle Menu Edit Template Pandas in Hindi What is Pandas in Hindi pandas  एक python library...

NumPy

NumPy Tutorial NumPy Hamburger Toggle Menu Edit Template NumPy in Hindi What is NumPy in Hindi matplotlib का use हम...

Edit Template
]]>
NumPy Exercise https://www.pyprohub.com/numpy-exercise Wed, 12 Feb 2025 08:16:55 +0000 https://pyprohub.com/?p=810
Edit Template
Edit Template
Edit Template

NumPy Exercise

Create a NumPy array with the elements [1, 2, 3, 4, 5].
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(arr)
[[1, 2, 3],
 [4, 5, 6]]
 
 
 import numpy as np
arr = np.array([[1, 2, 3], [4, 5, 6]])
print(arr)
import numpy as np
arr = np.zeros((3, 3))
print(arr)
import numpy as np
arr = np.random.rand(2, 4)
print(arr)
#array

arr = [1, 2, 3, 4, 5]

#solution

import numpy as np
arr = np.array([1, 2, 3, 4, 5])
mean_value = np.mean(arr)
print(mean_value)
#array

arr = [10, 20, 5, 30, 15]

#solution

import numpy as np
arr = np.array([10, 20, 5, 30, 15])
max_value = np.max(arr)
print(max_value)
#array

arr1 = [1, 2, 3]
arr2 = [4, 5, 6]

#solution

import numpy as np
arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])
dot_product = np.dot(arr1, arr2)
print(dot_product)
#array

arr1 = [1, 2, 3]
arr2 = [4, 5, 6]

#solution

import numpy as np
arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])
result = arr1 + arr2
print(result)
import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6])
reshaped_arr = arr.reshape(2, 3)
print(reshaped_arr)
#given 2d array

[[1, 2, 3],
 [4, 5, 6],
 [7, 8, 9]]
 
 #extract the subarry
 
 [[2, 3],
 [5, 6]]
 
 #solution
 
 import numpy as np
arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
subarray = arr[0:2, 1:3]
print(subarray)
  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
Python List

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python String

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Loops

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Conditional Statements

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Operators

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Data Type

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Scikit-learn

Scikit-learn Tutorial Scikit-learn Hamburger Toggle Menu Edit Template Scikit learn in Hindi What is Scikit-learn in Hindi Scikit learn एक...

Pandas

Pandas Tutorial Pandas Hamburger Toggle Menu Edit Template Pandas in Hindi What is Pandas in Hindi pandas  एक python library...

NumPy

NumPy Tutorial NumPy Hamburger Toggle Menu Edit Template NumPy in Hindi What is NumPy in Hindi matplotlib का use हम...

Edit Template
]]>
Scikit-learn Exercise https://www.pyprohub.com/scikit-learn-exercise Wed, 12 Feb 2025 06:24:51 +0000 https://pyprohub.com/?p=803
Edit Template
Edit Template
Edit Template

Scikit Learn Exercise

Fit a linear regression model to predict a target variable
from sklearn.linear_model import LinearRegression
import numpy as np

# Dummy dataset
X = np.array([[1], [2], [3], [4], [5]])
y = np.array([1.2, 1.9, 3.1, 4.2, 5.1])

# Model fitting
model = LinearRegression()
model.fit(X, y)

# Prediction
prediction = model.predict(np.array([[6]]))
print("Prediction for input 6:", prediction)
from sklearn.metrics import confusion_matrix

# True labels and predicted labels
y_true = [0, 1, 0, 1, 0, 1]
y_pred = [0, 1, 0, 0, 1, 1]

# Confusion Matrix
matrix = confusion_matrix(y_true, y_pred)
print("Confusion Matrix:\n", matrix)
from sklearn.linear_model import LogisticRegression
import numpy as np

# Dummy dataset
X = np.array([[1], [2], [3], [4], [5]])
y = np.array([0, 0, 0, 1, 1])  # 0 for ≤ 3, 1 for > 3

# Model fitting
model = LogisticRegression()
model.fit(X, y)

# Prediction
prediction = model.predict([[2], [4]])
print("Predictions:", prediction)
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification

# Generate dataset
X, y = make_classification(n_samples=100, n_features=4, random_state=42)

# Random Forest Classifier
clf = RandomForestClassifier()
clf.fit(X, y)

# Prediction
print("Prediction for first data point:", clf.predict([X[0]]))
from sklearn.neighbors import KNeighborsClassifier

# Dummy data
X = [[0], [1], [2], [3], [4], [5]]
y = [0, 0, 1, 1, 0, 0]  # 0 or 1 classes

# Model training
knn = KNeighborsClassifier(n_neighbors=3)
knn.fit(X, y)

# Prediction
prediction = knn.predict([[2]])
print("Prediction for input 2:", prediction)
from sklearn.cluster import KMeans
import numpy as np

# Dummy data
X = np.array([[1, 2], [1, 4], [1, 0],
              [4, 2], [4, 4], [4, 0]])

# K-means clustering
kmeans = KMeans(n_clusters=3, random_state=0)
kmeans.fit(X)
print("Cluster centers:\n", kmeans.cluster_centers_)
print("Labels for input points:", kmeans.labels_)
from sklearn.tree import DecisionTreeClassifier

# Dummy data
X = [[1], [2], [3], [4], [5], [6]]
y = [0, 0, 1, 1, 1, 0]

# Model training
tree = DecisionTreeClassifier()
tree.fit(X, y)

# Prediction
prediction = tree.predict([[3]])
print("Prediction for input 3:", prediction)
from sklearn.decomposition import PCA
from sklearn.datasets import load_iris

# Load dataset
iris = load_iris()
X = iris.data

# PCA
pca = PCA(n_components=2)
X_reduced = pca.fit_transform(X)
print("Reduced feature data:\n", X_reduced[:5])
from sklearn.preprocessing import StandardScaler
import numpy as np

X = np.array([[1], [10], [100], [1000]])

# Scaling
scaler = StandardScaler()
scaled_X = scaler.fit_transform(X)
print("Scaled Data:\n", scaled_X)
from sklearn import datasets
from sklearn.svm import SVC
from sklearn.model_selection import cross_val_score

# Load dataset
iris = datasets.load_iris()
X = iris.data
y = iris.target

# SVM Classifier
svm = SVC()

# Cross-validation
scores = cross_val_score(svm, X, y, cv=5)
print("Cross-validation scores:", scores)
  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
Python List

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python String

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Loops

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Conditional Statements

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Operators

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Data Type

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Scikit-learn

Scikit-learn Tutorial Scikit-learn Hamburger Toggle Menu Edit Template Scikit learn in Hindi What is Scikit-learn in Hindi Scikit learn एक...

Pandas

Pandas Tutorial Pandas Hamburger Toggle Menu Edit Template Pandas in Hindi What is Pandas in Hindi pandas  एक python library...

NumPy

NumPy Tutorial NumPy Hamburger Toggle Menu Edit Template NumPy in Hindi What is NumPy in Hindi matplotlib का use हम...

Edit Template
]]>
Python Exercise https://www.pyprohub.com/python-exercise Tue, 11 Feb 2025 07:38:09 +0000 https://pyprohub.com/?p=783
Edit Template
Edit Template
Edit Template

Python Exercise

Write a Python program to add two numbers provided by the user.
n1 = int(input("Enter 1st number: "))
n2 = int(input("Enter 2nd number: "))
sum = n1 + n2
print("The sum is:", sum)
n = int(input("Enter a number: "))
if n % 2 == 0:
    print("Even")
else:
    print("Odd")
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))

if a > b and a > c:
    print("Largest is:", a)
elif b > a and b > c:
    print("Largest is:", b)
else:
    print("Largest is:", c)
num = int(input("Enter a number: "))
factorial = 1
for i in range(1, num + 1):
    factorial *= i
print("Factorial of", num, "is", factorial)
string = input("Enter a string: ")
if string == string[::-1]:
    print("It is a palindrome")
else:
    print("It is not a palindrome")
n = int(input("Enter the number of terms: "))
a, b = 0, 1
for _ in range(n):
    print(a, end=" ")
    a, b = b, a + b
num = int(input("Enter a number: "))
is_prime = True
if num > 1:
    for i in range(2, int(num**0.5) + 1):
        if num % i == 0:
            is_prime = False
            break
else:
    is_prime = False
print("Prime" if is_prime else "Not prime")
string = input("Enter a string: ")
reversed_string = string[::-1]
print("Reversed string:", reversed_string)
num = input("Enter a number: ")
sum_of_digits = sum(int(digit) for digit in num)
print("Sum of digits:", sum_of_digits)
numbers = [10, 20, 4, 45, 99]
numbers.sort()
print("Second largest number is:", numbers[-2])
  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
Python List

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python String

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Loops

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Conditional Statements

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Operators

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String...

Python Data Type

Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Hamburger Toggle...

Scikit-learn

Scikit-learn Tutorial Scikit-learn Hamburger Toggle Menu Edit Template Scikit learn in Hindi What is Scikit-learn in Hindi Scikit learn एक...

Pandas

Pandas Tutorial Pandas Hamburger Toggle Menu Edit Template Pandas in Hindi What is Pandas in Hindi pandas  एक python library...

NumPy

NumPy Tutorial NumPy Hamburger Toggle Menu Edit Template NumPy in Hindi What is NumPy in Hindi matplotlib का use हम...

Edit Template
]]>