Python Operators

Mon 30 June 2025
a = 10
b = 3
print("Addition (+):", a + b)
print("Subtraction (-):", a - b)
print("Multiplication (*):", a * b)
print("Division (/):", a / b)
print("Floor Division (//):", a // b)
print("Modulus (%):", a % b)
print("Exponentiation (**):", a ** b)
x = 5
print("Initial x:", x)
x += 3
print("x += 3:", x)
x -= 2
print("x -= 2 …

Category: basics

Read More

Python Standard Modules

Mon 30 June 2025
# Example 0 using math module
import math
print('Square root of 0:', math.sqrt(0))
# Example 1 using random module
import random
print('Random number:', random.randint(0, 11))
# Example 2 using datetime module
from datetime import datetime, timedelta
print('Now + 2 days:', datetime.now() + timedelta(days=2))
# Example 3 …

Category: basics

Read More

Python Strings List Dict Set

Mon 30 June 2025
s = 'fpgfxda'
print(s.upper())
print(s[::-1])
print(len(s))
FPGFXDA
adxfgpf
7
s = 'ebhcmad'
print(s.upper())
print(s[::-1])
print(len(s))
EBHCMAD
damchbe
7
s = 'laolqyu'
print(s.upper())
print(s[::-1])
print(len(s))
LAOLQYU
uyqloal
7
s = 'faivrvazmc'
print(s.upper())
print(s[::-1 …

Category: basics

Read More

Regex Basics

Mon 30 June 2025
import re
text = "Contact us at sara123@gmail.com or call +91-9876543210"
email = re.findall(r"[a-zA-Z0-9._]+@[a-z]+\.[a-z]+", text)
print("Email:", email)
Email: ['sara123@gmail.com']
phone = re.findall(r"\+91-\d{10}", text)
print("Phone:", phone)
Phone: ['+91-9876543210']
Regex is used for pattern matching.
Useful in scraping …

Category: basics

Read More

Strings

Mon 30 June 2025
s = 'hello world'
print(len(s))
11
print(s.upper())
HELLO WORLD
print(s.lower())
hello world
print(s.capitalize())
Hello world
print(s.title())
Hello World
print(s.swapcase())
HELLO WORLD
print(s.startswith('hello'))
True
print(s.endswith('world'))
True
print(s.find('o'))
4
print(s.rfind …

Category: basics

Read More

Web Python Css Js

Mon 30 June 2025
<script>
for (let i = 0; i < 1; i++) {
    console.log('Loop 0 - iteration', i);
}
</script>
  Cell In[1], line 1
    <script>
    ^
SyntaxError: invalid syntax
<script>
function greet1() {
    console.log('Hello from function 1');
}
greet1();
</script>
<script>
let arr2 = [2, 3, 4];
console.log('Array 2:', arr2);
</script>
  Cell In[2 …

Category: basics

Read More
Page 4 of 4

« Prev