Python symbols list with examples pdf

Dennis 57 Published: 12/22/2024

Python symbols list with examples pdf

I'll respond in English as per your request.

Python is a high-level programming language that has gained immense popularity over the years. One of its notable features is the use of symbols to denote specific actions, operators, or functions. In this response, I'll provide you with a list of Python symbols along with examples and a downloadable PDF for further reference.

List of Python Symbols:

Assignment Operator (=) Example: x = 5 assigns the value 5 to variable x Addition (+) Example: x + 3 adds 3 to the value of x Subtraction (-)

Example: x - 4 subtracts 4 from the value of x Multiplication (*) Example: x * 2 multiplies the value of x by 2 Division (/ or //) Example: x / 3 divides the value of x by 3 (// is used for integer division) Modulus (%) Example: x % 2 finds the remainder of the value of x divided by 2 Exponentiation ( or *) Example: x ** 2 raises the value of x to the power of 2 (*** is used for exponentiation with more than two operands) Comparison Operators (=, !=, >, <, >=, <=) Example: x == 5 checks if the value of x is equal to 5 Logical Operators (and, or, not) Example: if x and y: checks if both x and y are True Membership Operators (in, not in) Example: x in list checks if the value of x is present in the list Identity Operators (is, is not) Example: x is 5 checks if the value of x is the same as 5 Bitwise Operators (&, |, ^, ~, <<, >>) Example: x & y performs a bitwise AND operation on x and y

Downloadable PDF:

You can download a comprehensive list of Python symbols with examples in PDF format from here.

Remember, this is not an exhaustive list, but it covers most of the commonly used Python symbols. With practice and experience, you'll become more familiar with these symbols and be able to write efficient and effective Python code.

Python symbols list with examples w3schools

I'm glad you asked! Here's a list of Python symbols with examples from W3Schools:

Arithmetic Operators

+ (Addition): a = 5; b = 2; print(a + b) Output: 7

- (Subtraction): a = 5; b = 2; print(a - b) Output: 3 * (Multiplication): a = 5; b = 2; print(a * b) Output: 10 / (Division): a = 5; b = 2; print(a / b) Output: 2.5 ** (Exponentiation): a = 5; b = 2; print(a ** b) Output: 25

Comparison Operators

== (Equal To): a = 5; b = 5; if a == b: print("True") != (Not Equal To): a = 5; b = 2; if a != b: print("True") > (Greater Than): a = 5; b = 2; if a > b: print("True") < (Less Than): a = 2; b = 5; if a < b: print("True") >= (Greater Than or Equal To): a = 5; b = 5; if a >= b: print("True") <= (Less Than or Equal To): a = 2; b = 2; if a <= b: print("True")

Logical Operators

and (And): a = True; b = False; if a and b: print("True") Output: False or (Or): a = True; b = False; if a or b: print("True") Output: True not (Not): a = True; if not a: print("True") Output: False

Assignment Operators

= (Assignment): a = 5; a = a + 2; print(a) Output: 7 += (Addition Assignment): a = 5; a += 2; print(a) Output: 7 -= (Subtraction Assignment): a = 5; a -= 2; print(a) Output: 3 *= (Multiplication Assignment): a = 5; a *= 2; print(a) Output: 10 /= (Division Assignment): a = 5; a /= 2; print(a) Output: 2.5

Membership Operators

in (In): fruits = ["apple", "banana", "cherry"]; if "apple" in fruits: print("True") not in (Not In): fruits = ["apple", "banana", "cherry"]; if "grape" not in fruits: print("True")

Identity Operators

is (Is): a = [1, 2, 3]; b = a; if a is b: print("True") is not (Is Not): a = [1, 2, 3]; b = []; if a is not b: print("True")

Bitwise Operators

& (And): a = 5; b = 3; c = a & b; print(c) Output: 1 | (Or): a = 5; b = 3; c = a | b; print(c) Output: 7 ^ (Xor): a = 5; b = 3; c = a ^ b; print(c) Output: 6 ~ (Not): a = 5; c = ~a; print(c) Output: -6 << (Left Shift): a = 5; c = a << 1; print(c) Output: 10 >> (Right Shift): a = 5; c = a >> 1; print(c) Output: 2

These are the basic Python symbols and their uses. W3Schools provides a vast array of tutorials, examples, and reference materials for web development and programming in general.