0% found this document useful (0 votes)
12 views

Python Revision Tour 1

Uploaded by

asthasurvanshi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Python Revision Tour 1

Uploaded by

asthasurvanshi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CBSE Class 12 Computer Science (Python)

Python Revision Tour I

Revision Notes

Start here in points.

 Statements are the instructions given to the computer to perform any kind of action.

 Python statements can be one of these types: empty statement, single statement and
compound statement.

 A compound statement represents a group of statements executed as a unit.

 Every compound statement of Python has a header and an indented body below the
header. Some examples of compound statements are: functions, if statement, while
statement etc.

 Python provides one selection statement if in many forms - if..else and if..elif..else.

 The statements that allow a set of instructions to be performed repeatedly are iteration
statements.

 Python provides two looping constructs - for and while. The for loop is a counting loop
and while is a conditional loop.

 The while loop is an entry-controlled loop as it has a control over entry in the loop in the
form of test condition.

 Loops in Python can have else clause too. The else clause of a loop is executed in the
end of the loop only when loop terminates normally.

 The break statement can terminate a loop immediately and the control passes over to
the statement following the statement containing break.

 In nested loops, a break statement terminates the very loop it appears in.

 The continue statement abandons the current iteration of the loop by skipping over the
rest of the statements in the loop-body. It immediately transfers control to the beginning
of the next iteration of the loop.

 Python strings are stored in memory by storing individual characters in contiguous


memory locations.
 The index (also called subscript sometimes) is the numbered position of a letter in the
string.

 In Python, indices begin 0 onwards in the forward direction up to length-1 and -1, -2, ....up
to - length in the backward direction. This is called two-way indexing.

 The string slice refers to a part of the string s[start:end) is the element beginning at start
and extending up to but not including end.

 Lists are mutable sequences of Python i.e., you can change elements of a list in place.

 Lists index their elements just like strings, i.e., two way indexing.

 Lists are similar to strings in many ways like indexing, slicing and accessing individual
element but they are different in the sense that Lists are mutable while strings are not.

 Membership operator in tells if an element is present in the sequence or not and not in
does the opposite.

 List slice is an extracted part of a list; list slice is a list in itself.

 L[start:stop] creates a list slice out of List L with elements falling between indexes start
and stop, not including stop.

 Tuples are immutable sequences of Python i.e., you cannot change the element of a
tuple in place.

 To create a tuple, put a number of comma-separated expressions in round brackets. The


empty round brackets i.e., () indicate an empty tuple.

 Tuples index their elements just like strings or lists, i.e., two way indexing.

 Tuples are stored in memory exactly like strings, except that because some of their
objects are larger than others, they store a reference at each index instead of single
character as in strings.

 Tuple slice is an extracted part of tuple; tuple slice is a tuple in itself.

 T[start:stop] creates a tuple slice out of tuple T with elements falling between indexes
start and stop, not including stop.

 Dictionaries are mutable with elements in the form of a key:value pair that associate
keys to values.

 The keys of a dictionary must be of immutable types.

 In Python dictionaries, the elements (key:value pairs) are unordered; one cannot access
element as per specific order.

 keys of a dictionary must be unique.

 In Dictionaries, the updation and addition of elements are similar in syntax. But for
addition, the key must not exist in the dictionary and for updation, the key must exist in
the dictionary.

 Sorting of an array means arranging the array elements in a specified order.

 In bubble sort, the adjoining values are compared and exchanged if they are not in proper
order. This process is repeated until the entire array is sorted.

 In insertion sort, each successive element is picked and inserted at an appropriate


position in the previously sorted array.

You might also like