Numbers in Python

Python में data को अलग-अलग formats में store किया जाता है, जिनमें से सबसे basic और important type है Numbers

Numbers का उपयोग mathematical calculations, counting, measurements और logical operations में किया जाता है।
यह programming का एक fundamental part है, क्योंकि लगभग हर program में numbers का use होता है।

Numbers क्या होते हैं

Python में Numbers ऐसे data types होते हैं जो numeric values को represent करते हैं।
इनका उपयोग addition, subtraction, multiplication, division जैसे operations के लिए किया जाता है।

Python में मुख्य रूप से तीन प्रकार के numbers होते हैं:

  • Integer (int)
  • Floating Point (float)
  • Complex Number (complex)

1. Integer (int)

परिभाषा

Integer वे numbers होते हैं जिनमें कोई decimal point नहीं होता।

ये positive, negative या zero हो सकते हैं।

Example

a = 10
b = -5
c = 0
print(a, b, c)

Output

10 -5 0

Explanation

यहाँ सभी values whole numbers हैं, इसलिए ये integer type के हैं।

2. Floating Point (float)

परिभाषा

Float वे numbers होते हैं जिनमें decimal point होता है।

इनका उपयोग fractional values को represent करने के लिए किया जाता है।

Example

x = 10.5
y = -3.2
print(x, y)

Output

10.5 -3.2

Explanation

यहाँ values decimal में हैं, इसलिए ये float type के numbers हैं।

3. Complex Number (complex)

परिभाषा

Complex numbers वे होते हैं जिनमें real और imaginary part होता है।
इन्हें a + bj के form में लिखा जाता है।

Example

z = 2 + 3j
print(z)

Output

(2+3j)

Explanation

यहाँ 2 real part है और 3 imaginary part है।
Complex numbers का use advanced mathematics और scientific calculations में होता है।

type() function का उपयोग

Python में किसी variable का type जानने के लिए type() function का use किया जाता है।

a = 10
b = 5.5
c = 2 + 3j
print(type(a))
print(type(b))
print(type(c))

Output

<class 'int'>
<class 'float'>
<class 'complex'>

Number Operations

Python में numbers पर कई operations किए जा सकते हैं:

a = 10
b = 3
print(a + b) # Addition
print(a - b) # Subtraction
print(a * b) # Multiplication
print(a / b) # Division

Real-life Example: Total marks निकालना

math = 80
science = 75
english = 85
total = math + science + english
print("Total Marks =", total)

Output

Total Marks = 240

Real-life Example: Average निकालना

total = 240
subjects = 3
average = total / subjects
print("Average =", average)

Output

Average = 80.0

Type Conversion (Casting)

कभी-कभी हमें एक number type को दूसरे type में convert करना पड़ता है।

a = 10
b = float(a)
print(b)

Output

10.0

Common mistakes

  1. integer और float को confuse करना
  2. division (/) हमेशा float result देता है
  3. complex numbers का syntax गलत लिखना

Simple complete program

a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
sum = a + b
print("Sum =", sum)

इस topic की मुख्य बात

Numbers Python का सबसे basic data type है।

इस topic में student यह सीखता है:

  • Numbers क्या होते हैं
  • int, float और complex में अंतर
  • mathematical operations
  • type checking और conversion
  • real-life calculations

Leave a Comment

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

Scroll to Top