இந்த பகுதியில் Python-ன் மூன்று முக்கியமான basic……
Tuple assignment, operator precedence, and comments.
1. Tuple Assignment
1. Tuple Assignment…
Tuple Assignment என்பது multiple value……
x, y = 10, 20 இதில்: x → 10 y → 20 Simple definit……
1. Operator Precedence…
Operator Precedence என்பது ஒரு expression-ல் multiple operators இருந்தால் எந்……
1. Comments…
Comments என்பது programmer explanation அல்லது no……
This is a comment
Simple definition: Programmer-க்கு பு……
Tuple Assignment Normally: x = 10 y = 20 Tuple assignment பயன்படுத்தினால்: x, y = 10, 20 இரண்டும் same re……
10 + 5 * 2 Wrong thinking: 10 + 5 = 15 15 * 2 = 30 P……
Student age
Student age
என்பது programmer note. Pytho……
மட்டுமே execute ஆகும்.…
Tuple Assignment Flow Multiple variables ↓ ……
a, b, c = 10, 20, 30 Flow: a ← 10 b ← 20 c ← 30 Operator Precedence Flow Expression ↓ Parentheses check ↓ Hig……
comment
This program adds two numbers
Tuple Assignment x, y = 10, 20…
Tuple assignment is also commonly called:
Multiple Assignment…
name, age, mark = "Arun", 20,……
name, age, mark = "Arun", 20,……
Assignment happens based on p……
Number of variables and values normally must match. Correct: x, y = 10, 20 Wrong: x, y = 10,……
Tuple Unpacking
Suppose: data = (10, 20, 30) ……
data = (100, 200, 300) x, y, ……
Tuple syntax usually uses parentheses: (10, 20, 30) But p……
Tuple Packing
Multiple values combined into……
This is called: Tuple Packing…
10 20 30 ↓ Packed together ↓ ……
Tuple Unpacking
Tuple values separated into v……
(10, 20, 30) ↓ Unpack ↓ a = 1……
Swapping Variables Using Tuple Assignment
Python-ல் two variables value……
Python: x, y = y, x…
x, y = y, x…
Initially: x = 10 y = 20 Statement: x, y = y, x Right side ……
Other languages-ல் swap செய்ய temporary variable தேவைப்படலா……
Tuple Assignment: Left ↔ Righ……
1st → 1st 2nd → 2nd 3rd → 3rd…
Tuple assignment allows multiple vari……
x, y = 10, 20…
What is tuple assignment in Python? Answer Tuple assignment allows multip……
How do you swap two variables in Python? Answer Use tuple assi……
Operator precedence determines which operati……
2 + 3 * 4 Both + and * are present. Python must decide: Additi……
School maths-ல்: 2 + 3 × 4 Mu……
Expression: 2 + 3 * 4 Operators: + * - h……
Basic Operator Precedence Order For beginner/exam understanding, remember roughly: Parentheses () E……
Basic arithmetic: P E M D A S P → Parentheses E → Exponent M → Multiplication D → Divi……
Calculation: 2 * 5 = 10 10 + ……
Calculation: 10 + 2 = 12 12 *……
Parentheses have very high priority. So whene……
Exponentiation Precedence
2 ** 3 Means: 2 × 2 × 2 Answe……
Why? First: 3 ** 2 = 9 Then: ……
** has higher precedence than……
Same Precedence Operators
20 / 5 * 2 / and * have similar precedence level. Eva……
Most same-level arithmetic operators associ……
2 ** 3 ** 2 Python interprets it l……
Exponentiation in Python is r……
Comparison Operator Precedence
10 + 5 > 12 Arithmetic occurs……
Logical Operator Precedence
Logical operators: not and or Precedence among them: no……
Why? First: False and False…
Then: True or False…
When expressions become complex, don't depend only ……
Always Left to Right என்று நி……
2 + 3 * 4 Python does not sim……
Parentheses Ignore செய்வது (2……
** same as * என்று நினைப்பது ……
2 * 3 → 6 2 ** 3 → 8…
For arithmetic: Bracket Power……
() → ** → *, /, //, % → +, -…
Operator precedence determine……
Parentheses can change the or……
Exponentiation ** has higher ……
Multiplication and division hav……
Logical precedence: not > and……
What is operator precedence? Answer Operator precedence determines the order in whic……
How can you control precedence explicitly? ……
(2 + 3) * 4…
A comment is explanatory text included in source……
Suppose code: x = 10 y = 20 print(x + y) Later பார்க்……
Add two numbers
Now program purpose easy-ஆக ப……
Programmer writes comment ↓ Python sees # ↓ R……
comment text
Calculate total
This program adds two numbers
Display the result
This program adds two numbers
Comment. Python does not exec……
Display the result
Comment. Line 5:…
Single-Line Comment
Most common Python comment us……
The comment does not appear i……
Inline Comment
Comment can also appear after……
Student age
Multiple Comment Lines
If multiple comment lines are……
This program
calculates the sum
of two numbers
Python does not have a special dedicated block-comment synt……
comment line 1
comment line 2
comment line 3
You may see: """ This is some text across multiple lines """ This is technically a triple……
Docstring
A docstring documents: Module……
Here: """Return the sum of tw……
Why Comments Are Useful Comments help in: Understanding code ……
Comment output-ல் வரும் என்று……
Hello
Hello does not print.…
// comment என்று நினைப்பது In……
comment
# inside a string comment என்……
Why? Because # is inside quotes……
= Comment
→ Note for humans
Code → Instruction for Python…
Python single-line comments b……
Comments are ignored during n……
Comments improve code readabi……
Triple-quoted strings are not……
A docstring is used to docume……
How do you write comments in Python? Answer Single-line comments begin w……
What is the difference between a comment and a docstring? Answer A comment uses # and……
Three Concepts in One Program…
Assign two values
x, y = 10, 20…
Multiplication is evaluated before addition
Here: x, y = 10, 20 → Tuple A……
Assign two values
→ Comment…
Why? First: y * 2 20 * 2 = 40……
Which is an example of tuple ……
What is the value of y? x, y ……
What is the output? x, y = 5,……
What is the result? 2 + 3 * 4…
What is the result? (2 + 3) *……
Which operator has higher pre……
What is the result? 2 ** 3…
Which symbol starts a Python ……
What is the output?…
print("Hello")
B. Python C. Hello Python D. ……
What is the output? print("#H……
is inside a string, so it is not treated as a comment.
What is the output? a, b, c =……
What is the result? 10 + 20 /……
Assign three values using one sta……
Swap these variables: a = 100……
Find the output: x, y = 5, 3 print(……
Find the output: print((5 + 3……
Find the output: print(2 ** 3……
Write a comment explaining this……
Add two numbers
What happens? x, y = 10, 20, 30 Answer: The num……
Identify: data = 10, 20, 30 A……
Identify: a, b, c = data Answ……
First value
Second value
Answer: 52…
Tuple assignment assigns multiple values to multiple variables in one statement. x, y = 10, 20 is tuple assig……
inside a string is not a comment.
Multiple comment lines can each begin with #. Doc……
x, y = 10, 20 → Tuple Assignment data = 10, 20 → Tuple Packing x, y = data ……
- / // % → Before + -…
2 + 3 * 4 → 14 (2 + 3) * 4 → ……
→ Python comment
Comments → Not executed "#Hello" → String, not comment Mem……