Skip to content

Commit 194d569

Browse files
committed
Added more operators
1 parent bcb97fd commit 194d569

File tree

2 files changed

+224
-2
lines changed

2 files changed

+224
-2
lines changed

.ipynb_checkpoints/Operators_in_Python-checkpoint.ipynb

+112-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,120 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "fd4d76b8-c348-435f-b1f2-fe711ca09fb0",
6+
"metadata": {},
7+
"source": [
8+
"### Operators in Python\n",
9+
"### ===================\n",
10+
"\n",
11+
"##### Operators are used to perform operations on variables and values. Python has the following operators:\n",
12+
"\n",
13+
"1. **Arithmetic's operators** \n",
14+
"2. **Comparison Operators** \n",
15+
"3. **Logical operators** \n",
16+
"4. **Bitwise operators**\n",
17+
"5. **Assignment operators**\n",
18+
"6. **Identity operators**\n",
19+
"7. **Membership operators**"
20+
]
21+
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": 25,
25+
"id": "579476a5-b4da-4a82-a81f-eed0955293cd",
26+
"metadata": {},
27+
"outputs": [
28+
{
29+
"name": "stdout",
30+
"output_type": "stream",
31+
"text": [
32+
"Arithmetic operators\n",
33+
"addition: 15\n",
34+
"Substration: 5\n",
35+
"Muliplication: 50\n",
36+
"Square: 100000\n",
37+
"Division: 2.0\n",
38+
"Modulus: 0\n",
39+
"Floor division: 3\n",
40+
"\n",
41+
"\n",
42+
"Comparison Operators\n",
43+
"False\n",
44+
"True\n",
45+
"False\n",
46+
"True\n",
47+
"True\n",
48+
"False\n",
49+
"\n",
50+
"\n",
51+
"Logical operators\n",
52+
"True\n",
53+
"False\n",
54+
"False\n",
55+
"True\n",
56+
"False\n",
57+
"\n",
58+
"\n",
59+
"Bitwise Operators\n",
60+
"2\n"
61+
]
62+
}
63+
],
64+
"source": [
65+
"x=5;\n",
66+
"y=10;\n",
67+
"## Arithmetic's operators \n",
68+
"print('Arithmetic operators')\n",
69+
"print('addition:', x + y)\n",
70+
"print('Substration:', y - x)\n",
71+
"print('Muliplication:', x*y)\n",
72+
"print('Square:', y**x) ## y to the power x // 10 to power 5 \n",
73+
"print('Division:', y/x)\n",
74+
"print('Modulus:', y%x) ## modules its return reminder \n",
75+
"print('Floor division:', y // 3) ## the floor division // rounds the result down to the nearest whole number\n",
76+
"\n",
77+
"\n",
78+
"## Comparison Operators\n",
79+
"print('\\n')\n",
80+
"print('Comparison Operators')\n",
81+
"print( x > y) ## greater then \n",
82+
"print(x < y) ## less then\n",
83+
"print(x >= y) ## greater then and equl to\n",
84+
"print(x <= y) ## less then and equal to \n",
85+
"print(x != y) ## not equal to \n",
86+
"print(x == y) ## equal to equal to \n",
87+
"\n",
88+
"## Logical operators\n",
89+
"print('\\n')\n",
90+
"print('Logical operators')\n",
91+
"x=True\n",
92+
"y=False\n",
93+
"print(x or y) ## OR operator which means any one is true then true\n",
94+
"x=False\n",
95+
"y=False\n",
96+
"print(x or y) \n",
97+
"\n",
98+
"print(x and y) ## and (&&) operator which means if both are true then true else false\n",
99+
"\n",
100+
"x=True\n",
101+
"y=True\n",
102+
"print(x and y) ## and (&&) operator which means if both are true then true else false \n",
103+
"print(not x) ## always returns oposite value \n",
104+
"\n",
105+
"\n",
106+
"## Bitwise Operators\n",
107+
"print('\\n')\n",
108+
"print('Bitwise Operators')\n",
109+
"x=6\n",
110+
"y=3\n",
111+
"print(x & y) ## The & operator compares each bit and set it to 1 if both are 1, otherwise it is set to 0\n"
112+
]
113+
},
3114
{
4115
"cell_type": "code",
5116
"execution_count": null,
6-
"id": "cd483008-d51e-4cb7-8963-c42008b8410a",
117+
"id": "732bdcd4-7b13-4faf-b958-acfdf6f06bc8",
7118
"metadata": {},
8119
"outputs": [],
9120
"source": []

Operators_in_Python.ipynb

+112-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,120 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "fd4d76b8-c348-435f-b1f2-fe711ca09fb0",
6+
"metadata": {},
7+
"source": [
8+
"### Operators in Python\n",
9+
"### ===================\n",
10+
"\n",
11+
"##### Operators are used to perform operations on variables and values. Python has the following operators:\n",
12+
"\n",
13+
"1. **Arithmetic's operators** \n",
14+
"2. **Comparison Operators** \n",
15+
"3. **Logical operators** \n",
16+
"4. **Bitwise operators**\n",
17+
"5. **Assignment operators**\n",
18+
"6. **Identity operators**\n",
19+
"7. **Membership operators**"
20+
]
21+
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": 25,
25+
"id": "579476a5-b4da-4a82-a81f-eed0955293cd",
26+
"metadata": {},
27+
"outputs": [
28+
{
29+
"name": "stdout",
30+
"output_type": "stream",
31+
"text": [
32+
"Arithmetic operators\n",
33+
"addition: 15\n",
34+
"Substration: 5\n",
35+
"Muliplication: 50\n",
36+
"Square: 100000\n",
37+
"Division: 2.0\n",
38+
"Modulus: 0\n",
39+
"Floor division: 3\n",
40+
"\n",
41+
"\n",
42+
"Comparison Operators\n",
43+
"False\n",
44+
"True\n",
45+
"False\n",
46+
"True\n",
47+
"True\n",
48+
"False\n",
49+
"\n",
50+
"\n",
51+
"Logical operators\n",
52+
"True\n",
53+
"False\n",
54+
"False\n",
55+
"True\n",
56+
"False\n",
57+
"\n",
58+
"\n",
59+
"Bitwise Operators\n",
60+
"2\n"
61+
]
62+
}
63+
],
64+
"source": [
65+
"x=5;\n",
66+
"y=10;\n",
67+
"## Arithmetic's operators \n",
68+
"print('Arithmetic operators')\n",
69+
"print('addition:', x + y)\n",
70+
"print('Substration:', y - x)\n",
71+
"print('Muliplication:', x*y)\n",
72+
"print('Square:', y**x) ## y to the power x // 10 to power 5 \n",
73+
"print('Division:', y/x)\n",
74+
"print('Modulus:', y%x) ## modules its return reminder \n",
75+
"print('Floor division:', y // 3) ## the floor division // rounds the result down to the nearest whole number\n",
76+
"\n",
77+
"\n",
78+
"## Comparison Operators\n",
79+
"print('\\n')\n",
80+
"print('Comparison Operators')\n",
81+
"print( x > y) ## greater then \n",
82+
"print(x < y) ## less then\n",
83+
"print(x >= y) ## greater then and equl to\n",
84+
"print(x <= y) ## less then and equal to \n",
85+
"print(x != y) ## not equal to \n",
86+
"print(x == y) ## equal to equal to \n",
87+
"\n",
88+
"## Logical operators\n",
89+
"print('\\n')\n",
90+
"print('Logical operators')\n",
91+
"x=True\n",
92+
"y=False\n",
93+
"print(x or y) ## OR operator which means any one is true then true\n",
94+
"x=False\n",
95+
"y=False\n",
96+
"print(x or y) \n",
97+
"\n",
98+
"print(x and y) ## and (&&) operator which means if both are true then true else false\n",
99+
"\n",
100+
"x=True\n",
101+
"y=True\n",
102+
"print(x and y) ## and (&&) operator which means if both are true then true else false \n",
103+
"print(not x) ## always returns oposite value \n",
104+
"\n",
105+
"\n",
106+
"## Bitwise Operators\n",
107+
"print('\\n')\n",
108+
"print('Bitwise Operators')\n",
109+
"x=6\n",
110+
"y=3\n",
111+
"print(x & y) ## The & operator compares each bit and set it to 1 if both are 1, otherwise it is set to 0\n"
112+
]
113+
},
3114
{
4115
"cell_type": "code",
5116
"execution_count": null,
6-
"id": "cd483008-d51e-4cb7-8963-c42008b8410a",
117+
"id": "732bdcd4-7b13-4faf-b958-acfdf6f06bc8",
7118
"metadata": {},
8119
"outputs": [],
9120
"source": []

0 commit comments

Comments
 (0)