Thursday, 13 June 2024

Class 7 - Chapter 6: Control Statements in Python

 Chapter 6: Control Statements in Python

A. Fill in the blanks.

1. Precedence 2. '+'

3. Control 

4. if-else 

5. Boolean

B. State True or False. 

1. False

2. True 

3. True 

4. False 

5. True

C. Select the correct option. 

1. a. Operands

2. b. 4

3. b. Sequential 

4. a. else

5. b. 25

D. Competency-based question.

Sumit should use the modulus operator (%). 

E. Answer the following questions.

1. ‘/’ is the Division operator used to divide the numbers and give an output in the decimal form. For example, the output of 5/2 is 2.5. On the other hand, ‘//’ is the Floor Division operator used to divide the numbers and give an output in the integer form. For example, the output of 5//2 is 2.

2. The '*' operator is used to replicate a given string a specified number of times. It is also known as the replication operator.

3. Operators are symbols that perform arithmetic, logical, and relational operations on operands and provide a meaningful result. Assignment operator (=) is used to assign the value of an expression to a variable.

4. Logical operators are used to combine the result of two or more relational expressions. For example, and, or and not. Whereas relational operators compare the values of the variables and determine the result in a Boolean expression, which is either 'True' or 'False'. For example, >, <, >=, <=, ==, and!=.

5. Unary Operators operate on only one operand. For example, a= +100 (the value assigned to 'a' is +100). Whereas binary Operators operate on two operands. For example, a+b. Here, '+' is a binary operator working on 'a' and 'b'.

6. In programming languages, conditional statements cause the program to control the transfer to a specific location depending on the outcome of the conditional expression. The different types of control structures are: Sequential, Conditional, and Iterative

7. The conditional statements check the condition and execute the statements accordingly. The different forms of conditional statements are:

if statement

if…else statement

if….elif…else statement

8. The syntax of if…else statement is: if <condition>:

statement set 1 else:

statement set 2


No comments:

Post a Comment

Class 7 - Chapter 8: Natural Language Processing

  C ha pter 8: Natural La n guage P r oc e ss i ng A. Fill in the blanks. 1. Natural Language Processing  2. AI 3. Tokenisation  4. NLG 5. ...