Modul 2 Python
Modul 2 Python
● Comments are ignored by the Python interpreter during the execution of the
program and serve as documentation for developers, making the code more
understandable
variables.
● Use CamelCase for class names.
● Avoid using single-character names unless they represent
● Arithmetic Operators
● Comparison Operators
● Logical Operators
● Assignment Operators
● Bitwise Operators
● Membership Operators
● Identity Operators
Arithmetic Operators
Comparison Operators
Logical Operators
Assignment Operators
Bitwise Operators
Membership Operators
In Operator:
Not in Operator
“In” Operators
“Not In” Operators
Identity Operators
1. ()
2. exponent **
3. multiplication and others * / ** % //
4. addition and subtraction + -
Sample Precedence of Operators
String Operations
● Concatenation
● Repetition
● String Length
● Indexing and Slicing
● String Methods
● String Formatting
● Checking Substring
Concatenation
In Python, you can find the length of a string (i.e., the number of
characters in the string) using the len()
Indexing & Slicing
In Python, you can use the input() function to get user input from
the console.
The input() function takes a prompt (a string) as an optional
argument, displays the prompt to the user, and then waits for the
user to enter some text
Sample Input()