What kind of programming language is Python, and what is it known for?

Python is a high-level, interpreted, general-purpose programming language that is widely recognized for its simplicity and readability. Created by Guido van Rossum and first released in 1991, Python emphasizes code clarity and a clean syntax, which makes it especially friendly for beginners — while still being powerful enough for professionals and large-scale applications.

6/2/20252 min read

🔹 Basic Python Questions
  1. What is Python?

    • Python is a high-level, interpreted, general-purpose programming language known for its readability and simplicity.

  2. What are Python’s key features?

    • Easy syntax, interpreted, dynamically typed, object-oriented, extensive libraries, cross-platform.

  3. What are Python's data types?

    • int, float, str, bool, list, tuple, set, dict, NoneType.

  4. How do you write a comment in Python?

    python

    # This is a comment

  5. What is a variable?

    • A variable is a named location used to store data in memory.

🔹 Control Flow Questions
  1. What are conditional statements in Python?

    python

    if condition:

    # code

    elif another_condition:

    # code

    else:

    # code

  2. What are loops in Python?

    • for loop:

      python

      for i in range(5):

      print(i)

    • while loop:

      python

      while condition:

      print("Looping")

  3. How do you break out of a loop?

    • Use break to exit, continue to skip an iteration.

🔹 Functions & Scope
  1. How do you define a function in Python?

    python

    def greet(name):

    return "Hello " + name

  2. What is the difference between global and local variables?

  • Local variables exist inside functions.

  • Global variables are declared outside and accessible inside functions using global keyword.

🔹 Data Structures
  1. How do you create a list?

python

my_list = [1, 2, 3]

  1. Difference between list and tuple?

  • List is mutable: []

  • Tuple is immutable: ()

  1. How to create a dictionary?

python

my_dict = {"name": "Alice", "age": 25}

  1. What is a set?

  • An unordered collection of unique items.

python

my_set = {1, 2, 3}

🔹 Object-Oriented Programming
  1. How do you define a class in Python?

python

class Person:

def__init__(self, name):

self.name = name

def greet(self):

return "Hello " + self.name

  1. What are init and self?

  • init is the constructor.

  • self refers to the current instance of the class.

🔹 File Handling
  1. How to read a file in Python?

python

with open("file.txt", "r") as f:

content = f.read()

  1. How to write to a file?

python

with open("file.txt", "w") as f:

f.write("Hello World")

🔹 Exception Handling
  1. How do you handle exceptions?

python

try:

x = 10 / 0

except ZeroDivisionError:

print("Cannot divide by zero")

finally: print("Always runs")

🔹 Miscellaneous Questions
  1. What is a lambda function?

python

add = lambda x, y: x + y

print(add(2, 3)) # 5

  1. What is list comprehension?

python

squares = [x*x for x in range(5)]

  1. How do you install a package in Python?

bash

pip install package_name

  1. What is a module and a package?

  • Module: A Python file with functions/classes.

  • Package: A collection of modules in a directory with init.py.

  1. What is the difference between is and ==?

  • is checks identity.

  • == checks equality of values.