CodeLangs AISoftware Training Institute
Python for Beginners (Marathi)/Python Data Types
Dashboard
Chapter 5 · Python Fundamentals

Python Data Types

2,697
words
13
min read
30
practice items
Interactive learning

Practice lab

Question 1 of 14 00:00

या chapter मध्ये आपण Python मधील fundamental data types शिकणार आहोत: int, float, complex, str, bool, None आणि value चा type तपासण्यासाठी type().

Version Note: या chapter मधील examples Python 3.14.x ला लागू आहेत. September 2026 मध्ये Python 3.14.7 ही latest stable release आहे; Python 3.15.0rc2 ही अजून pre-release आहे.

Learning Outcomes#

हा chapter पूर्ण केल्यानंतर तुम्ही:

  • Python मध्ये value चा data type का महत्त्वाचा आहे हे explain करू शकाल.
  • int, float, complex, str, bool आणि None ओळखू शकाल.
  • कोणत्या प्रकारच्या data साठी कोणता data type योग्य आहे हे decide करू शकाल.
  • type() वापरून value किंवा variable चा runtime type तपासू शकाल.
  • int आणि float मधील practical फरक समजू शकाल.
  • Python complex number मध्ये j का वापरतो हे ओळखू शकाल.
  • True आणि False हे Boolean values योग्य context मध्ये वापरू शकाल.
  • None म्हणजे zero, False किंवा empty string नाही हे स्पष्ट करू शकाल.
  • floating-point values वापरताना precision संबंधित basic limitation ओळखू शकाल.
  • beginner-level interview questions confidently answer करू शकाल.

1. Data Type म्हणजे काय?#

Suppose तुम्ही एका application मध्ये खालील information store करत आहात:

PYTHON
student_age = 22
course_price = 499.99
student_name = "Rahul"
is_enrolled = True

चारही variables मध्ये data आहे.

पण तो data सारखा नाही.

  • 22 हे whole number आहे.
  • 499.99 हे decimal number आहे.
  • "Rahul" हा text आहे.
  • True ही logical value आहे.

Python ला या values सोबत कोणत्या operations करता येतील हे समजण्यासाठी value चा type महत्त्वाचा असतो.

Definition

A data type describes the kind of value an object represents and the operations that can be performed on it.

मराठीत अर्थ

Data type म्हणजे एखादी value कोणत्या प्रकारची आहे आणि त्या value वर कोणत्या प्रकारचे operations करता येऊ शकतात हे दर्शवणारी माहिती.

उदाहरण:

PYTHON
age = 25
name = "Amit"

age मध्ये number आहे.

name मध्ये text आहे.

म्हणून Python या दोन्ही values वेगवेगळ्या प्रकारे handle करतो.

Python मध्ये numeric types मध्ये int, float आणि complex हे distinct built-in types आहेत. bool हा int चा subtype आहे.


2. int — Integer#

Imagine तुम्हाला employee चे age, number of attempts, quantity किंवा user ID सारखी whole-number information store करायची आहे.

तेथे int उपयोगी पडतो.

Definition

An int represents a whole number without a decimal point.

मराठीत अर्थ

int हा decimal point नसलेला पूर्ण number दर्शवतो.

Examples:

PYTHON
age = 25
quantity = 10
temperature = -5
score = 0

या सर्व values चा type int आहे.

PYTHON
age = 25

print(type(age))

Expected Output:

TEXT
<class 'int'>

Positive, Negative आणि Zero#

int फक्त positive number नसतो.

हे सर्व integers आहेत:

PYTHON
positive_number = 100
negative_number = -50
zero = 0

Large Integers#

Python integers सामान्य fixed 32-bit किंवा 64-bit integer limit पर्यंतच मर्यादित नसतात. Python int arbitrary precision support करतो; practical limit available memory वर अवलंबून असते.

उदाहरण:

PYTHON
large_number = 999999999999999999999999999999999999999999

print(large_number)
print(type(large_number))

तुम्हाला beginner म्हणून त्याची internal implementation जाणून घेण्याची गरज नाही.

महत्त्वाचे हे:

Python मध्ये मोठे whole numbers सामान्य int म्हणून store करता येतात.

Practical Uses of int#

int सामान्यतः वापरला जातो:

  • age
  • quantity
  • count
  • number of students
  • retry attempts
  • product stock
  • year
  • order count
  • database ID represent करताना application level वर

उदाहरण:

PYTHON
total_students = 45
available_seats = 12
login_attempts = 3

3. float — Decimal Number#

Suppose तुमच्या e-commerce application मध्ये product price आहे:

TEXT
499.99

हा whole number नाही.

त्यात decimal point आहे.

अशा values साठी Python मध्ये साधारणपणे float वापरला जातो.

Definition

A float represents a floating-point number, commonly used for values with a fractional part.

मराठीत अर्थ

float हा decimal किंवा fractional part असलेला number represent करण्यासाठी वापरला जाणारा numeric type आहे.

Examples:

PYTHON
price = 499.99
temperature = 36.5
percentage = 87.25

Check type:

PYTHON
price = 499.99

print(type(price))

Expected Output:

TEXT
<class 'float'>

10 आणि 10.0 सारखे दिसतात का?#

Mathematically:

TEXT
10 = 10.0

पण Python type च्या दृष्टीने:

PYTHON
whole_value = 10
decimal_value = 10.0

print(type(whole_value))
print(type(decimal_value))

Expected Output:

TEXT
<class 'int'>
<class 'float'>

म्हणजे:

ValueType
10int
10.0float
-8int
-8.5float
Decimal point असलेली numeric literal साधारणतः float असते, even if fractional part zero असेल.

Floating-Point Precision#

Now think carefully.

तुम्हाला असे वाटू शकते:

PYTHON
print(0.1 + 0.2)

Output exactly 0.3 असेल.

प्रत्यक्षात सामान्य Python floating-point representation मध्ये output असा दिसू शकतो:

TEXT
0.30000000000000004

हे Python calculation चुकीचे आहे म्हणून होत नाही.

Python float सामान्यतः binary floating-point representation वापरतो आणि काही decimal fractions binary मध्ये exact represent करता येत नाहीत. Python documentation नुसार floating-point numbers सामान्यतः C double representation वर आधारित असतात.

Beginner level वर लक्षात ठेवा:

float म्हणजे exact decimal arithmetic guarantee नाही.

उदाहरणार्थ money calculations सारख्या domains मध्ये exact decimal behavior आवश्यक असल्यास वेगळ्या approaches वापरल्या जाऊ शकतात; त्याचा detailed अभ्यास या chapter च्या scope बाहेर आहे.


Practical Uses of float#

PYTHON
product_price = 1499.50
average_rating = 4.7
body_temperature = 36.8
completion_percentage = 82.5

4. complex — Complex Number#

Python मध्ये complex numbers सुद्धा built-in support आहेत.

Complex number मध्ये दोन parts असतात:

TEXT
real part + imaginary part

Python imaginary part दर्शवण्यासाठी j वापरतो.

Example:

PYTHON
number = 3 + 4j

येथे:

  • real part = 3
  • imaginary part = 4
Definition

A complex value represents a number with a real part and an imaginary part.

मराठीत अर्थ

complex type अशा number ला represent करतो ज्यामध्ये real part आणि imaginary part असतात.

Check:

PYTHON
number = 3 + 4j

print(number)
print(type(number))

Expected Output:

TEXT
(3+4j)
<class 'complex'>

Python complex number चे .real आणि .imag parts access करता येतात. Documentation नुसार हे components floating-point values म्हणून उपलब्ध असतात.

PYTHON
number = 3 + 4j

print(number.real)
print(number.imag)

Expected Output:

TEXT
3.0
4.0

Important: Python मध्ये j, i नाही#

Mathematics मध्ये imaginary number साठी अनेकदा i notation दिसते.

Python syntax मध्ये:

PYTHON
number = 2 + 3j

हे valid आहे.

पण:

PYTHON
number = 2 + 3i

हे valid complex-number syntax नाही.

Python complex literals imaginary part साठी j वापरतात.

Complex Numbers कुठे उपयोगी पडतात?#

Beginner applications मध्ये complex तुम्हाला int, float किंवा str इतका frequently दिसणार नाही.

पण तो उपयोगी असू शकतो:

  • scientific computing
  • electrical engineering
  • signal processing
  • mathematical calculations

या chapter मध्ये तुम्हाला complex mathematics शिकण्याची गरज नाही.

फक्त data type समजणे आवश्यक आहे.


5. Numeric Types एकत्र समजून घेऊ#

आत्तापर्यंत:

PYTHON
student_count = 50
average_marks = 78.5
signal_value = 2 + 3j

Types:

PYTHON
print(type(student_count))
print(type(average_marks))
print(type(signal_value))

Expected Output:

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

Comparison:

TypeExampleTypical Meaning
int50whole number
float78.5decimal/fractional numeric value
complex2 + 3jreal + imaginary number

6. str — String#

Suppose तुम्हाला खालील information store करायची आहे:

  • student name
  • email
  • city
  • course name
  • message

ही माहिती numbers नाही.

ही text आहे.

Python मध्ये text represent करण्यासाठी str वापरतो.

Definition

A str represents text as a sequence of Unicode characters.

मराठीत अर्थ

str म्हणजे text represent करणारा type; त्यामध्ये characters ची sequence असते.

Example:

PYTHON
student_name = "Rahul"
course_name = "Python Beginner Course"
city = "Pune"

Check type:

PYTHON
course_name = "Python Beginner Course"

print(type(course_name))

Expected Output:

TEXT
<class 'str'>

Quotes महत्त्वाचे आहेत#

हा:

PYTHON
age = 25

int आहे.

पण:

PYTHON
age = "25"

str आहे.

Check:

PYTHON
number_value = 25
text_value = "25"

print(type(number_value))
print(type(text_value))

Expected Output:

TEXT
<class 'int'>
<class 'str'>

दोन्ही visually 25 दाखवू शकतात.

पण type वेगळा आहे.

Quotes value चा अर्थ बदलू शकतात. "25" हा number नसून string आहे.

Single आणि Double Quotes#

दोन्ही valid आहेत:

PYTHON
first_name = 'Rahul'
course_name = "Python Beginner Course"

दोन्हींचा type:

TEXT
<class 'str'>

Empty String#

String मध्ये characters नसले तरी तो stringच असतो.

PYTHON
message = ""

print(type(message))

Expected Output:

TEXT
<class 'str'>

"" म्हणजे empty string.

तो None नाही.

हा फरक पुढे महत्त्वाचा ठरेल.


Strings in Real Projects#

PYTHON
username = "dattatray"
email = "student@example.com"
course_title = "Python Beginner Course"
status_message = "Enrollment successful"

Text-oriented application data मध्ये str हा अत्यंत common type आहे.


7. bool — Boolean#

Suppose application ला एखादी condition represent करायची आहे:

TEXT
User logged in आहे का?
Payment successful आहे का?
Course purchased आहे का?
Email verified आहे का?

या प्रश्नांची natural answers:

TEXT
Yes / No
True / False

Python मध्ये bool यासाठी वापरला जातो.

Definition

A bool represents one of two truth values: True or False.

मराठीत अर्थ

bool हा logical truth value represent करतो आणि त्याच्या फक्त दोन values असतात: True आणि False.

Python documentation नुसार Boolean type चे exactly दोन constant instances आहेत: True आणि False.

Examples:

PYTHON
is_logged_in = True
is_payment_failed = False

Check type:

PYTHON
is_logged_in = True

print(type(is_logged_in))

Expected Output:

TEXT
<class 'bool'>

Capitalization महत्त्वाची आहे#

Correct:

PYTHON
is_active = True
is_deleted = False

Incorrect:

PYTHON
is_active = true
is_deleted = false

Python मध्ये Boolean constants:

TEXT
True
False

capital letter ने सुरू होतात.


Real-World Example#

PYTHON
is_course_purchased = True
is_email_verified = False

print(is_course_purchased)
print(is_email_verified)

Expected Output:

TEXT
True
False

Good to Know: bool आणि int#

Python मध्ये bool हा int चा subclass आहे. Numeric contexts मध्ये False आणि True अनुक्रमे 0 आणि 1 सारखे behave करू शकतात, परंतु Python documentation explicit numeric intent असल्यास explicit conversion prefer करण्याचे सुचवते.

Beginner म्हणून मुख्य rule:

Logical information साठी True / False वापरा; numbers म्हणून Boolean वापरण्यावर design करू नका.

8. None — No Value / Absence of Value#

Now suppose user ने अजून profile photo select केलेला नाही.

तुम्हाला variable ठेवायचा आहे:

PYTHON
profile_photo = ?

तुम्ही 0 ठेवू शकत नाही कारण photo number नाही.

False ठेवले तर logical state वाटेल.

"" ठेवले तर empty text वाटेल.

Python मध्ये अशा परिस्थितीत None उपयोगी पडतो.

Definition

None is a special value used to represent the absence of a value.

मराठीत अर्थ

None ही विशेष value आहे जी सध्या meaningful value उपलब्ध नाही किंवा value absent आहे हे दर्शवण्यासाठी वापरली जाते.

Example:

PYTHON
selected_course = None

Check:

PYTHON
selected_course = None

print(selected_course)
print(type(selected_course))

Expected Output:

TEXT
None
<class 'NoneType'>

महत्त्वाचे:

None ही value आहे.

तिचा type:

TEXT
NoneType

None हे काय नाही?#

None म्हणजे:

TEXT
0

नाही.

None म्हणजे:

TEXT
False

नाही.

None म्हणजे:

TEXT
""

नाही.

हे वेगवेगळे concepts आहेत.

ValueMeaningType
0numeric zeroint
Falsefalse truth valuebool
""empty textstr
Noneabsence of a valueNoneType

Practical Example#

Suppose search operation अजून perform झालेली नाही:

PYTHON
search_result = None

नंतर code check करू शकतो:

PYTHON
if search_result is None:
    print("No result is available yet.")

Expected Output:

TEXT
No result is available yet.

None compare करताना:

PYTHON
value is None

हा standard आणि clear approach आहे.


9. type() — Value चा Type तपासणे#

Beginners ना अनेकदा हा प्रश्न पडतो:

Variable मध्ये value आहे, पण तिचा type कसा कळेल?

Python मध्ये built-in type() function वापरता येतो.

Definition

The type() function returns the type of an object.

मराठीत अर्थ

type() function दिलेल्या object/value चा type कोणता आहे ते सांगतो.

Example:

PYTHON
age = 25

print(type(age))

Expected Output:

TEXT
<class 'int'>

सर्व Types एकत्र तपासू#

PYTHON
age = 25
price = 199.99
signal = 2 + 3j
course = "Python"
is_active = True
result = None

print(type(age))
print(type(price))
print(type(signal))
print(type(course))
print(type(is_active))
print(type(result))

Expected Output:

TEXT
<class 'int'>
<class 'float'>
<class 'complex'>
<class 'str'>
<class 'bool'>
<class 'NoneType'>

type() Learning Tool म्हणून#

Development मध्ये type() debugging आणि learning साठी useful आहे.

Suppose:

PYTHON
value = "100"

तुम्हाला वाटले की value numeric आहे.

Check:

PYTHON
print(type(value))

Output:

TEXT
<class 'str'>

आता लगेच समजते:

"100" हा string आहे, integer नाही.

10. Complete Connected Example#

Imagine तुम्ही online course system तयार करत आहात.

PYTHON
student_id = 101
course_price = 999.50
calculation_value = 2 + 5j
student_name = "Snehal"
is_purchased = True
coupon_code = None

print(student_id, type(student_id))
print(course_price, type(course_price))
print(calculation_value, type(calculation_value))
print(student_name, type(student_name))
print(is_purchased, type(is_purchased))
print(coupon_code, type(coupon_code))

Expected Output:

TEXT
101 <class 'int'>
999.5 <class 'float'>
(2+5j) <class 'complex'>
Snehal <class 'str'>
True <class 'bool'>
None <class 'NoneType'>

या छोट्या example मध्ये एकाच application मध्ये वेगवेगळ्या kinds of values naturally कशा coexist करतात हे दिसते.


Practical / Real-World Application#

Scenario: Online Course Enrollment#

Requirement:

एका learning platform ला student बद्दल खालील information ठेवायची आहे:

  • unique student number
  • student name
  • course fee
  • purchase completed आहे की नाही
  • referral code अजून मिळालेला नसेल तर no value

Reasoning:

RequirementSuitable ValueType
Student number1001int
Student name"Rahul"str
Course fee799.50float
Purchased?Truebool
Referral code unavailableNoneNoneType

Implementation:

PYTHON
student_id = 1001
student_name = "Rahul"
course_fee = 799.50
is_purchased = True
referral_code = None

print(student_id)
print(student_name)
print(course_fee)
print(is_purchased)
print(referral_code)

Possible mistake:

PYTHON
is_purchased = "True"

हे Boolean नाही.

हा string आहे.

Better:

PYTHON
is_purchased = True

Why?

कारण variable logical state represent करतो.


Scenario: Inventory#

PYTHON
product_name = "Wireless Keyboard"
available_quantity = 25
product_price = 1499.99
is_available = True
discount_code = None

यात प्रत्येक value चा type तिच्या meaning शी logically match होतो.

हेच professional programming मधील basic data modeling चे foundation आहे.


Common Mistakes & Misconceptions#

Mistake 1: "100" आणि 100 एकच आहेत#

Why it sounds believable:

दोन्ही screen वर 100 दिसतात.

Correct understanding:

PYTHON
print(type(100))
print(type("100"))

Expected Output:

TEXT
<class 'int'>
<class 'str'>

Quotes मुळे दुसरी value text बनते.


Mistake 2: Decimal नसलेला float integer होतो#

PYTHON
value = 10.0

ही value:

TEXT
float

आहे.

PYTHON
print(type(10.0))

Expected Output:

TEXT
<class 'float'>

Mistake 3: None म्हणजे zero#

Wrong assumption:

TEXT
None == 0

असा conceptual अर्थ घेणे चुकीचे आहे.

0 हा actual numeric value आहे.

None absence of value दर्शवतो.


Mistake 4: None म्हणजे False#

दोघे वेगवेगळ्या उद्देशासाठी आहेत.

PYTHON
value_a = False
value_b = None

print(type(value_a))
print(type(value_b))

Expected Output:

TEXT
<class 'bool'>
<class 'NoneType'>

Mistake 5: true आणि false valid Boolean values आहेत#

Incorrect:

PYTHON
status = true

Correct:

PYTHON
status = True

Python मध्ये capitalization महत्त्वाची आहे.


Mistake 6: Python complex numbers मध्ये i वापरतो#

Incorrect concept:

TEXT
3 + 4i

Python complex literal:

PYTHON
number = 3 + 4j

Mistake 7: प्रत्येक decimal calculation mathematically exact दिसेल#

PYTHON
print(0.1 + 0.2)

तुम्हाला:

TEXT
0.30000000000000004

असे दिसू शकते.

हे floating-point representation चे characteristic आहे.


Mistake 8: Variable चा permanent fixed type असतो#

Beginner ला कधी कधी वाटते:

PYTHON
value = 10

म्हणजे value कायम intच राहील.

Python मध्ये variable name एखाद्या object ला reference करतो आणि नंतर त्याच name ला वेगळ्या type ची value assign केली जाऊ शकते:

PYTHON
value = 10
print(type(value))

value = "Python"
print(type(value))

Expected Output:

TEXT
<class 'int'>
<class 'str'>

महत्त्वाचे:

Python मध्ये type हा value/object शी संबंधित असतो; variable name ला एकच permanent type lock केलेला नसतो.

Hands-On Practice#

Practice 1 — Identify the Type#

खालील प्रत्येक value चा type आधी स्वतः predict करा:

PYTHON
100
45.75
-8
"45.75"
False
None
5 + 2j

Solution#

ValueType
100int
45.75float
-8int
"45.75"str
Falsebool
NoneNoneType
5 + 2jcomplex

Practice 2 — Choose Suitable Data Types#

Requirement:

एका student चे खालील data represent करा:

  • age = 24
  • name = Amit
  • course fee = 1250.50
  • active account = yes
  • mentor अजून assign झालेला नाही

Attempt first.

Solution#

PYTHON
age = 24
name = "Amit"
course_fee = 1250.50
is_active = True
mentor = None

Explanation:

  • age → whole number → int
  • name → text → str
  • course fee → decimal numeric value → float
  • active state → yes/no → bool
  • mentor unavailable → None

Practice 3 — Find the Mistakes#

PYTHON
student_name = Rahul
is_verified = true
course_fee = "999.50"
mentor = "None"

समस्या शोधा.

Solution#

PYTHON
student_name = "Rahul"
is_verified = True
course_fee = 999.50
mentor = None

Reasoning:

  • text quotes मध्ये असणे आवश्यक.
  • Boolean constant True आहे.
  • numeric fee text म्हणून store करण्याची गरज नाही.
  • absence of value साठी special None value वापरली आहे, "None" string नाही.

Practice 4 — Inspect Types#

Code लिहा जो खालील variables चे types display करेल:

PYTHON
order_id = 501
amount = 799.99
customer = "Neha"
paid = False
tracking_number = None

Solution#

PYTHON
order_id = 501
amount = 799.99
customer = "Neha"
paid = False
tracking_number = None

print(type(order_id))
print(type(amount))
print(type(customer))
print(type(paid))
print(type(tracking_number))

Expected Output:

TEXT
<class 'int'>
<class 'float'>
<class 'str'>
<class 'bool'>
<class 'NoneType'>

Practice 5 — Reason About Meaning#

Which design is better?

Option A:

PYTHON
is_logged_in = "yes"

Option B:

PYTHON
is_logged_in = True

Solution#

Option B.

PYTHON
is_logged_in = True

कारण variable logical state represent करतो. bool त्या meaning ला directly represent करतो.


Interview Preparation#

1. What is a data type in Python?

A data type describes the kind of value an object represents and determines what operations are meaningful for that value.

What the interviewer is testing: Whether you understand that Python values have types and that types are not merely labels.


2. What is the difference between int and float?

int represents whole numbers such as 10, 0, and -25. float represents floating-point numbers such as 10.5, 0.0, and -3.75.

Example:

PYTHON
a = 10
b = 10.0

print(type(a))
print(type(b))

Output:

TEXT
<class 'int'>
<class 'float'>

3. Is 10.0 an integer in Python?

No. 10.0 is a float because it is written as a floating-point literal.


4. What is the complex type in Python?

The complex type represents numbers containing a real part and an imaginary part.

Example:

PYTHON
value = 3 + 4j

Here, 3 is the real part and 4 is the imaginary part.


5. Why does Python use j in complex number literals?

Python syntax uses j or J to represent the imaginary part of a complex number.

Example:

PYTHON
value = 2 + 5j

6. What is a string in Python?

A string is a str object used to represent text as a sequence of Unicode characters.

Example:

PYTHON
name = "Rahul"

7. What is the difference between 100 and "100"?

100 is an integer, while "100" is a string.

PYTHON
print(type(100))
print(type("100"))

Output:

TEXT
<class 'int'>
<class 'str'>

Common weak answer: “They contain the same value.”

They may display similar characters, but their types and intended meanings are different.


8. What values can a Boolean have in Python?

A Boolean has two values:

PYTHON
True
False

Their type is bool.


9. Is bool related to int in Python?

Yes. bool is a subclass of int. In numeric contexts, False and True can behave like 0 and 1, although Boolean values should normally be used to represent logical states.


10. What is None in Python?

None is a special value that represents the absence of a value. Its type is NoneType.

PYTHON
result = None

print(type(result))

Output:

TEXT
<class 'NoneType'>

11. Is None the same as 0?

No.

0 is an integer value. None represents the absence of a value.


12. Is None the same as an empty string?

No.

PYTHON
value1 = None
value2 = ""

value1 has type NoneType, while value2 has type str.


13. What does the type() function do?

type() returns the type of an object.

Example:

PYTHON
value = 25
print(type(value))

Output:

TEXT
<class 'int'>

14. Can the same Python variable name refer to values of different types?

Yes.

PYTHON
value = 10
value = "Python"

The name value first refers to an integer object and later refers to a string object.


15. Why can 0.1 + 0.2 produce 0.30000000000000004?

Python floating-point numbers are generally represented using binary floating-point. Some decimal fractions cannot be represented exactly in binary, so small representation differences can appear.

What the interviewer is testing: Whether you recognize basic floating-point precision behavior rather than assuming every decimal value is stored exactly.


16. How would you represent a value that has not been assigned yet?

A common choice is None.

Example:

PYTHON
selected_user = None

Quick Revision#

ConceptRemember
intwhole number
floatfloating-point number
complexreal + imaginary number
strtext
boolTrue or False
Noneabsence of a value
type()returns an object's type

Important examples:

PYTHON
10          # int
10.5        # float
2 + 3j      # complex
"Python"    # str
True        # bool
None        # NoneType
"10" आणि 10 वेगळे आहेत.
10.0 हा float आहे.
None, 0, False आणि "" हे एकच नाहीत.
Python Boolean values True आणि False capital letters ने सुरू होतात.
Complex literals मध्ये imaginary part साठी j वापरला जातो.
type() वापरून actual runtime type तपासता येतो.

You Should Now Be Able To#

या chapter नंतर तुम्ही independently:

  • int, float, complex, str, bool आणि None ओळखू शकता.
  • value साठी suitable basic data type निवडू शकता.
  • "10" आणि 10 मधील फरक explain करू शकता.
  • 10 आणि 10.0 मधील type difference explain करू शकता.
  • Boolean logical states model करू शकता.
  • absence of value साठी None कधी useful आहे हे सांगू शकता.
  • type() वापरून values inspect करू शकता.
  • floating-point precision चा beginner-level issue ओळखू शकता.
  • Python complex literal identify करू शकता.
  • basic Python data-types interview questions answer करू शकता.

Final Challenge#

Scenario#

तुम्ही online learning platform च्या student enrollment feature साठी data model चा basic Python prototype तयार करत आहात.

Requirements:

  1. Student ID whole number आहे.
  2. Student name text आहे.
  3. Course price decimal value आहे.
  4. Student ने payment केले आहे.
  5. Mentor अजून assign केलेला नाही.
  6. एका mathematical demonstration साठी complex value 4 + 2j ठेवायची आहे.
  7. प्रत्येक variable चा type display करायचा आहे.

Learner Task#

Suitable values आणि data types वापरून Python code लिहा.

Hint 1#

Logical state साठी bool विचारात घ्या.

Hint 2#

Unavailable mentor ला fake string देऊ नका.

Hint 3#

Type तपासण्यासाठी chapter मधील built-in function वापरा.

Solution#

PYTHON
student_id = 1005
student_name = "Priya"
course_price = 1299.50
is_paid = True
mentor = None
demo_number = 4 + 2j

print(type(student_id))
print(type(student_name))
print(type(course_price))
print(type(is_paid))
print(type(mentor))
print(type(demo_number))

Expected Output:

TEXT
<class 'int'>
<class 'str'>
<class 'float'>
<class 'bool'>
<class 'NoneType'>
<class 'complex'>

Reasoning#

  • student_id → whole number → int
  • student_name → text → str
  • course_price → decimal → float
  • is_paid → logical state → bool
  • mentor → currently absent → None
  • demo_number → real + imaginary → complex
  • type() → each value चा type inspect करतो