Welcome to My CS Lab

Explore my coding problems, solutions, and experiments in Python. Each challenge is a step toward innovation.

Fibonacci Sequence

Generate the first N Fibonacci numbers using Python.
def fibonacci(n):
    a, b = 0, 1
    for _ in range(n):
        print(a, end=" ")
        a, b = b, a + b

fibonacci(10)

Factorial

Calculate the factorial of a number using recursion in Python.
def factorial(n):
    if n == 0:
        return 1
    return n * factorial(n-1)

print(factorial(5))

Reverse a String

Reverse a string without using built-in reverse functions.
def reverse_string(s):
    return s[::-1]

print(reverse_string("Arfan"))
© 2026 Arfan Sagid