Variables and Data Types in Python
Python में Variables और Data Types
What is Variables and Data Types?
Variables and Data Types means variables store values in memory. Python automatically detects common data types like int, float, string, boolean, list and dictionary.
In real programs, this topic helps in storing names, marks and totals. Learn the idea first, then type the program yourself and compare the output.
| Point | Details |
|---|---|
| Course Area | Core Python Basic programming concepts used to write Python programs. |
| Main Use | storing names, marks and totals |
| Example File | variables-data-types.py |
| Practice Focus | Run, change values, and explain the output line by line. |
Why should you learn this?
- It is useful for storing names, marks and totals.
- It connects with checking data type before calculation.
- It improves your ability to read, write and debug Python programs.
Important Terms
These terms are used directly in this lesson. Understand them before memorising the code.
| Term | Meaning |
|---|---|
| variable | A name that stores a value in memory for later use. |
| int | Whole number data type, such as 10 or -5. |
| float | Decimal number data type, such as 91.5. |
| string | Text data written inside quotes, such as "Hello". |
| type() | Built-in function used to check the data type of a value. |
Syntax / Basic Pattern
The simple pattern is: prepare data, apply the concept, then show the result.
student_name = "Aarav" age = 16 percentage = 91.5 is_pass = True print(student_name, age, percentage, is_pass) print(type(student_name)) print(type(age)) print(type(percentage))
Complete Example Program
student_name = "Aarav" age = 16 percentage = 91.5 is_pass = True print(student_name, age, percentage, is_pass) print(type(student_name)) print(type(age)) print(type(percentage)) print(type(is_pass))
Expected Output
Program Explanation
student_name = "Aarav"stores a value in student_name.age = 16stores a value in age.percentage = 91.5stores a value in percentage.is_pass = Truestores a value in is_pass.print(student_name, age, percentage, is_pass)displays information or calculated result on the screen.print(type(student_name))displays information or calculated result on the screen.print(type(age))displays information or calculated result on the screen.
Where will you use it?
- Storing names, marks and totals.
- Checking data type before calculation.
- Creating forms and reports.
Common Mistakes
- Writing code with wrong indentation.
- Using input() value directly in calculations without converting it to int or float.
- Using unclear variable names that make the program difficult to understand.
Practice Tasks
- Type the program in
variables-data-types.pyand run it. - Change input values or sample data and observe the new output.
- Create one example related to storing names, marks and totals.
- Write 5 lines explaining the logic in your own words.
Summary
Variables and Data Types is not a theory-only topic. You should be able to explain the meaning, write the example, run it successfully, and use it in a small practical program.
Variables और Data Types क्या है?
Variables और Data Types ka matlab hai: Variables store values in memory. Python automatically detects common data types like int, float, string, boolean, list and dictionary. Simple words me, ye topic practical Python programs likhne me direct use hota hai.
Is topic ko sirf definition ke liye nahi, balki storing names, marks and totals jaise real examples ke liye practice karein.
यह क्यों सीखना जरूरी है?
- Ye storing names, marks and totals me kaam aata hai.
- Ye checking data type before calculation se bhi connected hai.
- Isse aap code ka output aur errors better samajh paate hain.
Important Terms
| Term | Meaning |
|---|---|
| variable | A name that stores a value in memory for later use. |
| int | Whole number data type, such as 10 or -5. |
| float | Decimal number data type, such as 91.5. |
| string | Text data written inside quotes, such as "Hello". |
| type() | Built-in function used to check the data type of a value. |
Syntax / Basic Pattern
Basic idea: pehle data तैयार करें, phir Python logic apply करें, aur finally result display करें.
student_name = "Aarav" age = 16 percentage = 91.5 is_pass = True print(student_name, age, percentage, is_pass) print(type(student_name)) print(type(age)) print(type(percentage))
Complete Example Program
student_name = "Aarav" age = 16 percentage = 91.5 is_pass = True print(student_name, age, percentage, is_pass) print(type(student_name)) print(type(age)) print(type(percentage)) print(type(is_pass))
Expected Output
Program Explanation
student_name = "Aarav"stores a value in student_name.age = 16stores a value in age.percentage = 91.5stores a value in percentage.is_pass = Truestores a value in is_pass.print(student_name, age, percentage, is_pass)displays information or calculated result on the screen.print(type(student_name))displays information or calculated result on the screen.print(type(age))displays information or calculated result on the screen.
Practical Uses
- Storing names, marks and totals.
- Checking data type before calculation.
- Creating forms and reports.
Common Mistakes
- Writing code with wrong indentation.
- Using input() value directly in calculations without converting it to int or float.
- Using unclear variable names that make the program difficult to understand.
Practice Tasks
- Program ko
variables-data-types.pyfile me type karke run karein. - Values change karke output compare karein.
- storing names, marks and totals par ek छोटा example banayen.
- Logic ko apne words me 5 lines me likhein.
सारांश
Variables and Data Types ko tab complete maanenge jab aap iska meaning, example, output aur practical use clearly explain kar saken.