Introduction to Python

Python is an interpreted, high-level programming language known for its readability and versatile usage—from web development and data science to automation and AI.

Example 1: Hello World

print("Hello, World!")
Run Code on OneCompiler

Example 2: Addition

a = 5 b = 3 print("Sum =", a + b)
Run Code on OneCompiler

Example 3: Loop

for i in range(1, 6): print(i)
Run Code on OneCompiler

Example 4: Function

def multiply(x, y): return x * y print("Product =", multiply(4, 5))
Run Code on OneCompiler

🧠 Python Quiz

  1. What function is used to display output?
  2. How do you define a function?
  3. Which keyword is used for loops?