You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 01.Variables/README.md
+37-22Lines changed: 37 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,25 +10,40 @@ Welcome to the Python Variables section! In this section, you'll learn about the
10
10
## 📚 Table of Contents
11
11
12
12
-[Variables](#-variables)
13
-
-[String Variables](#-string-variables)
14
-
-[Float Variables](#-float-variables)
15
-
-[Integer Variables](#-integer-variables)
16
-
-[Boolean Variables](#-boolean-variables)
13
+
-[Datatype](#-data-type)
14
+
-[String Dataype](#-string-datatype)
15
+
-[Float Dataype](#-float-datatype)
16
+
-[Integer Dataype](#-integer-datatype)
17
+
-[Boolean Dataype](#-boolean-datatype)
17
18
## 📚 Variables
18
19
19
20
Variables are containers for storing data values. In Python, you don't need to declare the type of a variable, as Python is dynamically typed. This means you can assign different types of values to the same variable.
20
21
21
-
## 📜 String Variables
22
-
23
-
- In this section, you'll learn about string variables in Python, including how to create them, perform operations like concatenation, slicing, and more.
22
+
```python
23
+
a =1
24
+
b =True
25
+
c ="Vibhav"
26
+
d =None
27
+
```
28
+
- These are four variables of different data types.
29
+
---
30
+
## 📊 Data Type
31
+
Data type specifies the type of value a variable holds. This is required in programming to do various operations without causing an error.
32
+
In python, we can print the type of any operator using type function:
33
+
```python
34
+
a =1
35
+
print(type(a))
36
+
b ="1"
37
+
print(type(b))
38
+
```
24
39
25
-
### What is a String Variable?
40
+
##📜 String Datatype
26
41
27
-
- A string variable is used to store text data. In Python, you can create a string variable by enclosing text in single quotes (`'`) or double quotes (`"`). Strings are immutable, meaning that once a string is created, it cannot be changed.
42
+
- A string is used to store text data. In Python, you can create a string variable by enclosing text in single quotes (`'`) or double quotes (`"`). Strings are immutable, meaning that once a string is created, it cannot be changed.
28
43
29
-
### Creating String Variables
44
+
### Creating String Datatype
30
45
31
-
- You can create a string variable by assigning a string to a variable name.
46
+
- You can create a string by assigning a string to a variable name.
- A float variable is used to store numbers with a decimal point. Floats are useful when you need precision for calculations involving fractions or when you need to represent real numbers.
100
+
- A float is used to store numbers with a decimal point. Floats are useful when you need precision for calculations involving fractions or when you need to represent real numbers.
86
101
87
-
### Creating Float Variables
102
+
### Creating Float Datatype
88
103
89
-
- You can create a float variable by assigning a number with a decimal point to a variable name.
104
+
- You can create a float by assigning a number with a decimal point to a variable name.
An integer variable is used to store whole numbers (without a decimal point). Integers can be both positive and negative. They are commonly used for counting and indexing.
171
+
An integer is used to store whole numbers (without a decimal point). Integers can be both positive and negative. They are commonly used for counting and indexing.
157
172
158
-
### Creating Integer Variables
173
+
### Creating Integer Datatype
159
174
160
175
- You can create an integer variable by assigning a whole number to a variable name.
161
176
@@ -222,13 +237,13 @@ string_number = "123"
222
237
integer_number =int(string_number)
223
238
print(integer_number) # Output: 123
224
239
```
225
-
# ✅ Boolean Variables
240
+
# ✅ Boolean Datatype
226
241
227
-
A boolean variable is used to store one of two values: `True` or `False`. Booleans are often used in conditional statements and loops to control the flow of a program.
242
+
A boolean is used to store one of two values: `True` or `False`. Booleans are often used in conditional statements and loops to control the flow of a program.
228
243
229
-
### Creating Boolean Variables
244
+
### Creating Boolean Datatype
230
245
231
-
- You can create a boolean variable by assigning `True` or `False` to a variable name.
246
+
- You can create a boolean by assigning `True` or `False` to a variable name.
0 commit comments