0% found this document useful (0 votes)
13 views2 pages

Comp

Uploaded by

Aneeta Sujith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Comp

Uploaded by

Aneeta Sujith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1 Statements ● Instructions written in programming language

● Also called source code


● Smallest executable unit within python
● Types
○ Empty - pass
○ Simple- assignment statement, computation stmnt
○ Compound- comprises a group of stmnt

2 Control and flow 1. Sequential statement


a. Executed in a sequential order
b. Default flow of statements
2. Selection statement
a. Statement to be executed is decided by a condition
b. Eg: if…else statements
3. Iterative or looping statement
a. If a certain set of statements needs to be executed multiple
times.
b. Iteration: the set of statements that is repeated again and
again
c. Condition on which the loop exits: exit or test condition

3 indentation ● Adding white spaces before a statement


● If not indented properly- IndentationError
● Statement in same indentation= block of code

4 Conditional 1. If statement
statements 2. if - else statement
3. If-elif-else statement
4. nested -if statement

5 If statement ● If the condition is true - program is executed


● If the condition is false do nothing

6 If-else statement ● ‘if’ , ‘else’ are keywords


● If the condition is true- statement inside if is executed
● If the condition is false- statement inside else is executed

7 if -elif-else ● When multiple conditions is to be checked


● If the statement associated with ‘if’ is true- it is executed
● And the rest of the ladder is bypassed
● If none of the conditions are true - executes else statement
○ Else is optional
○ No. of elif == no of conditions

8 Nested if-elif-else ● Allows to check multiple test expressions and different codes for
more that two conditions
● We can have if-elif-else statement inside another if-else statement
9 Iteration ● Repetition of a set of statement
● A loop statement allows us to execute a statement or group of
statements multiple times

10 Types of loops 1. For loop - definite loops (stmnt executed for a definite no of times)
2. While loop - indefinite loop

11 For loop ● Used to iterate over a range of values or sequence


● When all the items in the range are exhausted, the body of the loop
is not executed anymore
● Sequence maybe list,tuple or string
● ‘else’ statement is executed after all the iterations

12 Range function ● Used to create a list containing a start and a stop


● range([start],stop,[step])
● Start and step are optional
● Arguments of range() function should be integers

13 While loop ● Executed as long as the condition holds true


● When the test outcome of the condition is false, loop breaks

14 Jump statement ● Used to alter the flow of control unconditionally


● Different jump statements are
○ Break
○ Pass
○ continue

15 Break statement ● Terminates the current loop and resume execution at the next
statement immediately after the end of the loop

16 Continue statement ● When encountered jumps to the beginning of the loop for next
iteration
● skips the execution of statements inside the body of the loop

17 Pass statement ● When a statement is required syntacticallyBut you do not want any
comment or code to execute

You might also like