Questions & Answers
1. What is meant by string concatenation?
String concatenation means joining two
or more strings together to form a single string. In
Python, the + operator is commonly used
for string concatenation.
first_name = "Anant" last_name = "Sir" name = first_name + " " + last_name print(name)
2. What are conditional statements in Python?
Conditional statements allow a
Python program to make decisions and execute
different blocks of code depending on whether a
condition is True or False.
The main conditional statements are
if, if-else, and
if-elif-else.
marks = 75
if marks >= 40:
print("Pass")
else:
print("Needs improvement")
3. How does Python determine which part of an expression to evaluate first?
Python uses operator precedence to determine the order in which operators in an expression are evaluated. Operators with higher precedence are evaluated before operators with lower precedence.
Parentheses can be used to explicitly control the order of evaluation.
result = 2 + 3 * 4 print(result)
Multiplication is performed before addition.
Therefore, the expression is evaluated as
2 + (3 * 4).
4. What do you mean by iterative statements?
Iterative statements are statements that repeatedly execute a block of code. They are also called looping statements.
Python provides for and
while loops for performing repeated
operations.
for i in range(1, 4):
print(i)
1
2
3
5. What is the difference between relational and logical operators?
Relational operators compare two
values and produce a Boolean result,
True or False.
Logical operators combine or modify
Boolean conditions.
| Type | Purpose | Operators | Example |
|---|---|---|---|
| Relational | Compare two values. |
==,
!=,
>,
<,
>=,
<=
|
10 > 5 → True
|
| Logical | Combine or negate Boolean conditions. |
and,
or,
not
|
age >= 18 and citizen
|
Quick Revision
| Concept | Key Point |
|---|---|
| String Concatenation | Joining two or more strings, commonly using +. |
| Conditional Statements | Used to make decisions based on conditions. |
| Operator Precedence | Determines the order in which operators are evaluated. |
| Iterative Statements | Repeat a block of code using loops. |
| Relational Operators | Compare values and return Boolean results. |
| Logical Operators | Combine or negate Boolean conditions. |
Key Terms to Remember
Boolean:
A data type with two logical values:
True and False.
Condition:
An expression that can be evaluated as
True or False.
Loop: A programming construct used to repeat a block of statements.
Operator Precedence: The rules that determine the order in which operators are evaluated in an expression.