Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 079cbcc

Browse files
new
1 parent 7fe38fc commit 079cbcc

File tree

2 files changed

+55
-10
lines changed

2 files changed

+55
-10
lines changed

‎Day 1/notes and codes.md‎

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
|--|--|--|
1414
|1|Intro to python|[Click Here](#intro-to-python)|
1515
|2|Defining a variable|[Click Here](#defining-a-variable)|
16-
|3|Data Types in Python|[Click Here](#data-types-in-python)|
17-
|3-1|String Data Type|[Click Here](#3-1-string-data-type)|
18-
|3-2|Numeric Data Type|[Click Here](#3-2-numeric-data-type)|
19-
|3-3|Boolean & None Data Type|[Click Here](#3-3-boolean-and-none-data-type)|
20-
|3-4|Collection Data Type|[Click Here](#3-4-collection-data-type)|
16+
|3|Rules for Defining Variables in Python|[Click Here](#rules-for-defining-variables-in-python)|
17+
|4|Data Types in Python|[Click Here](#data-types-in-python)|
18+
|4-1|String Data Type|[Click Here](#4-1-string-data-type)|
19+
|4-2|Numeric Data Type|[Click Here](#4-2-numeric-data-type)|
20+
|4-3|Boolean & None Data Type|[Click Here](#4-3-boolean-and-none-data-type)|
21+
|4-4|Collection Data Type|[Click Here](#4-4-collection-data-type)|
2122

2223

2324
## Intro to Python
@@ -72,6 +73,50 @@ Try experimenting with different variable names and values to solidify your unde
7273

7374
**[🔝Index](#index)**
7475

76+
---
77+
78+
## Rules for Defining Variables in Python
79+
80+
When defining variables in Python, there are a few rules and guidelines to follow to ensure your code runs correctly and is easy to read. Let’s take a look at these essential rules:
81+
82+
**1. Variable names must begin with a letter or an underscore (_).**
83+
- Valid: `x`, `_my_variable`, `age`
84+
- Invalid: `1age`, `@variable`
85+
86+
**2. Variable names can only contain letters (a-z, A-Z), numbers (0-9), and underscores (_).**
87+
- Valid: `my_var`, `age_123`, `my_variable`
88+
- Invalid: `my-variable`, `my variable`
89+
90+
**3. Variable names are case-sensitive.**
91+
- `age`, `Age`, and `AGE` are considered different variables in Python.
92+
93+
**4. Avoid using Python keywords as variable names.**
94+
- Keywords are reserved words in Python, and they have special meanings. You can’t use them as variable names. Examples of keywords include: `if`, `else`, `for`, `while`, `def`, `class`, etc.
95+
- Valid: `variable`, `my_var`
96+
- Invalid: `if`, `else`, `while`
97+
98+
**5. Variable names should be descriptive and follow a consistent naming convention.**
99+
- Use **snake_case** for variable names (e.g., `user_age`, `total_price`).
100+
- Avoid one-letter variables unless in specific cases (e.g., `x`, `y` in mathematical operations).
101+
102+
**6. You can reassign variables to different data types.**
103+
- Since Python is dynamically typed, you can change the type of a variable during the execution of a program.
104+
- Example:
105+
```python
106+
x = 10 # x is an integer
107+
x = "Hello" # x is now a string
108+
```
109+
110+
**7. Whitespace (spaces, tabs) is not allowed within variable names.**
111+
- Valid: `first_name`, `total_score`
112+
- Invalid: `first name`, `total score`
113+
114+
**8. Variables cannot start with a number.**
115+
- Valid: `age1`, `score_100`
116+
- Invalid: `1age`, `100_score`
117+
118+
**[🔝Index](#index)**
119+
75120
---
76121
## Data Types in Python
77122

@@ -87,7 +132,7 @@ Each type has unique properties and methods, and Python automatically manages me
87132

88133
**[🔝Index](#index)**
89134

90-
### 3-1 String Data Type
135+
### 4-1 String Data Type
91136

92137
Strings (`str`) in Python represent sequences of Unicode characters. Strings are **immutable**, meaning once created, they cannot be changed directly.
93138

@@ -107,7 +152,7 @@ print(greeting) # Output: Hello, Alice!
107152
108153
**[🔝Index](#index)**
109154
110-
### 3-2 Numeric Data Type
155+
### 4-2 Numeric Data Type
111156
112157
Python has three main numeric types:
113158
@@ -132,7 +177,7 @@ print(a / b) # Float division, output: 3.3333333333333335
132177
133178
**[🔝Index](#index)**
134179
135-
### 3-3 Boolean and None Data Type
180+
### 4-3 Boolean and None Data Type
136181
137182
**Boolean (bool)**
138183
- Represents truth values: True and False.
@@ -163,7 +208,7 @@ if result is None:
163208
164209
**[🔝Index](#index)**
165210
166-
### 3-4 Collection Data Type
211+
### 4-4 Collection Data Type
167212
168213
Python provides several built-in collection data types that group multiple values into a single variable. These collections are versatile and widely used to store, organize, and manipulate data.
169214

‎intro video.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Day 1 - Summary and Useful Links
1+
# Intro to Python for beginners course
22

33
## Topics Covered
44
- [What is Python? Its Use Cases (Web, Data, Automation)](#what-is-python-its-use-cases-web-data-automation)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /