Module 3 - Strings, Operators, and Controls
Module 3 - Strings, Operators, and Controls
Strings,
Operators, and
Controls
Module 3
1
Click to edit Master title style
Outline:
• More on Strings
• Operators
• Control Structures
2
Click toMethods
String edit Master title style
• str.capitalize() Returns the copy of the string with its first character
capitalized and the rest of the letters are in lowercase
• string.casefold() Returns a lowered case string. It is similar to the
lower() method, but the casefold() method converts more characters into
lower case.
• string.center() Returns a new centered string of the specified length,
which is padded with the specified character. The deafult character is
space.
• string.count() Searches (case-sensitive) the specified substring in the
given string and returns an integer indicating occurrences of the substring.
• string.endswith() Returns True if a string ends with the specified
suffix (case-sensitive), otherwise returns False.
3
Click toMethods
String edit Master title style
6
Click to Operators
Python edit Master title style
7
Click to Categories
Python edit Masterof
title style
Operators
• Arithmetic Operators
• Assignment Operators
• Comparison Operators
• Logical Operators
• Identity Operators
• Membership Test Operators
• Bitwise Operators
8
Click to editOperators
Arithmetic Master title style
9
ClickoftoArithmetic
List edit Master title style
Operators
10
ClickoftoArithmetic
List edit Master title style
Operators
11
ClickoftoArithmetic
List edit Master title style
Operators
12
Click to edit Operators
Assignment Master title style
13
Click to edit Operators
Assignment Master title style
14
Click to edit Operators
Assignment Master title style
15
Click to edit Operators
Assignment Master title style
16
Click to edit Operators
Comparison Master title style
• The comparison operators compare two operands and return a
boolean either True or False.
17
Click to edit Operators
Comparison Master title style
• The comparison operators compare two operands and return a
boolean either True or False.
18
Click to edit Operators
Comparison Master title style
• The comparison operators compare two operands and return a
boolean either True or False.
19
Click to Operators
Logical edit Master title style
• The logical operators are used to combine two boolean expressions. The logical operations are
generally applicable to all objects, and support truth tests, identity tests, and boolean operations.
20
Click to edit
Identity Master title style
Operators
• The identity operators check whether the two objects have the same id
value e.i. both the objects point to the same memory location.
21
Click to edit Master
Membership title style
Operators
• The membership test operators in and not in test whether the sequence has a given item or
not. For the string and bytes types, x in y is True if and only if x is a substring of y.
22
Click to Operators
Bitwise edit Master title style
23
Click to Operators
Bitwise edit Master title style
24
Click to Operators
Bitwise edit Master title style
25
Click to edit[09]
Simulation Master title style
26
Click to -edit
Python Master
if, elif, else title style
Conditions
27
Click to Syntax
Python edit Master title style
28
Click to -edit
Python Master
if, elif, else title style
Conditions
29
Click to -edit
Python Master
if, elif, else title style
Conditions
Along with the if statement, the else condition can be optionally used
to define an alternate block of statements to be executed if the
boolean expression in the if condition evaluates to False.
30
Click to -edit
Python Master
if, elif, else title style
Conditions
Use the elif condition is used to include multiple conditional
expressions after the if condition or between the if and else
conditions.
The elif block is executed if the specified condition evaluates to True.
31
Click to -edit
Python Master
if, elif, else title style
Conditions
Python supports nested if, elif, and else condition. The inner condition
must be with increased indentation than the outer condition, and all
the statements under the one block should be with the same
indentation.
32
Click to edit[10]
Simulation Master title style
33