print("=== Python Demo: 11 Examples ===\n")
# 2. Variables and arithmetic
print("2) Variables & Arithmetic:")
print(f"a = {a}, b = {b}, sum = {a + b}\n")
fruits = ["apple", "banana", "cherry"]
print(f"First fruit: {fruits[0]}")
print(f"All fruits: {', '.join(fruits)}\n")
# 4. Dictionaries (hashes)
print("4) Dictionaries:")
ages = {"Alice": 25, "Bob": 30}
print(f"Alice is {ages['Alice']} years old\n")
print("5) Conditionals:")
print(f"{a} is greater than {b}\n")
print(f"{b} is greater or equal to {a}\n")
print(f"Loop iteration {i}")
print(greet("Python User"))
print("8) File Handling (write & read):")
with open(filename, "w") as f:
f.write("This is a test file.\n")
with open(filename, "r") as f:
print(f"Read: {line.strip()}")
print("9) Regular Expressions:")
text = "Python is powerful"
if re.search("powerful", text):
print("Match found in text!\n")
# 10. Command-line arguments
print("10) Command-line Arguments:")
print("Arguments passed:", " ".join(sys.argv[1:]), "\n")
print("No arguments provided\n")
# 11. Function using shift-like behavior
print("11) Function with shift-like behavior:")
args = list(args) # convert tuple to list
x = args.pop(0) # similar to shift (remove first)
y = args.pop(0) # next argument
result = add_numbers(10, 20)
print(f"10 + 20 = {result}")
print("\n=== End of Demo ===")