Loading samples...
Loading samples...
py-sample-20
Complete Python knowledge test
What is Python's design philosophy?
Which is NOT a Python feature?
What does GIL stand for?
What is a Python package?
Which is used for web development?
What is the latest Python 3 version?
Which is standard GUI library?
What is pip?
Which executes Python bytecode?
What is Jupyter Notebook?
Explain Python's execution model: source code to execution.
[3 marks]What makes Python beginner-friendly yet powerful?
[3 marks]Explain Python's memory management and garbage collection.
[3 marks]What are Python's key strengths and weaknesses?
[3 marks]Explain the difference between Python 2 and Python 3.
[3 marks]What is the Python Software Foundation? Role and importance?
[3 marks]Explain Python's standard library philosophy.
[3 marks]What is CPython, and how is it different from other implementations?
[3 marks]Explain Python's approach to concurrency: threading, multiprocessing, asyncio.
[3 marks]What are Python's most popular applications and domains?
[3 marks]Write a complete command-line TODO application with file persistence.
[5 marks]Create a simple HTTP API client using only standard library (urllib).
[5 marks]Implement a password manager with encryption using cryptography library.
[5 marks]Write a web scraper that extracts and saves data from HTML.
[5 marks]Create a multithreaded file downloader with progress display.
[5 marks]Implement a mini testing framework with decorators and assertions.
[5 marks]Predict output: import sys print(sys.version_info[:2])
[2 marks]Explanation:sys.version_info is a named tuple. [:2] gets (major, minor), e.g., (3, 12) for Python 3.12.
Find issue: def process(items=[]): for i in items: yield i * 2 items.append(1)
[3 marks]Explanation:Mutable default modified after first use. Append happens after yield loop completes. Subsequent calls see modified default.
Predict behavior: import threading counter = 0 def inc(): global counter for _ in range(1000): counter += 1 threads = [threading.Thread(target=inc) for _ in range(10)] [t.start() for t in threads] [t.join() for t in threads] print(counter)
[3 marks]Explanation:No locking. += is not atomic. Threads read-modify-write concurrently causing lost updates. Use Lock or atomic operations.
Find error: async def fetch(url): return requests.get(url) results = [fetch(u) for u in urls]
[3 marks]Explanation:Should use 'await fetch(u)' inside async function, or asyncio.gather(). List comprehension creates coroutines but doesn't run them.
Predict output: from dataclasses import dataclass @dataclass class Point: x: float y: float p = Point(1, 2) print(p)
[2 marks]Explanation:@dataclass automatically generates __init__, __repr__, __eq__. Clean syntax for data containers.
Find issue: def outer(): x = 10 def inner(): print(x) x = 20 inner() outer()
[3 marks]Explanation:Python sees 'x = 20' in inner, makes x local to inner. But 'print(x)' tries to read before assignment.
Predict output: class Config: _instance = None def __new__(cls): if cls._instance is None: cls._instance = super().__new__(cls) return cls._instance a = Config() b = Config() print(a is b)
[2 marks]Explanation:Singleton pattern using __new__. _instance stored in class. Subsequent calls return same instance.
Find issue: with open('data.txt', 'r') as f: data = f.readlines() for line in data: process(line) print('Processed', len(data), 'lines')
[2 marks]Explanation:readlines() loads entire file. Better: 'for line in f:' iterates lazily. Memory efficient for large files.