📝 20 Questions ⏱️ 30 minutes ✅ Instant Feedback 🎯 Passing Score: 70%

Module 1 Quiz: Python Fundamentals for AI

Test your knowledge of modern Python, libraries, async programming, and package management

Q1
Which Python package manager is written in Rust and known for being significantly faster than pip?
✅ Correct! uv is a Rust-based Python package manager that's 10-100x faster than pip. It's becoming increasingly popular in 2025 for AI projects.
Q2
What is the main purpose of Pydantic in Python applications?
✅ Correct! Pydantic provides data validation and settings management using Python type hints. It's essential for validating API responses in AI applications.
Q3
Which library is used for making asynchronous HTTP requests in Python?
✅ Correct! aiohttp is the most popular library for async HTTP requests. While httpx also supports async, aiohttp is more widely used in production AI applications.
Q4
What keyword is used to define an asynchronous function in Python?
✅ Correct! async def is used to define an asynchronous function (coroutine). You use await to call async functions.
Q5
Which function from the asyncio module is used to run an async main function?
✅ Correct! asyncio.run(main()) is the entry point for running async code. It creates an event loop, runs the coroutine, and closes the loop.
Q6
What is the purpose of python-dotenv?
✅ Correct! python-dotenv loads environment variables from a .env file into os.environ. This is essential for managing API keys securely.
Q7
What is the correct way to create a virtual environment using Python's built-in venv module?
✅ Correct! python -m venv .venv creates a virtual environment. The -m flag runs the venv module.
Q8
Which library is typically used for making synchronous HTTP requests in Python?
✅ Correct! The requests library is the most popular choice for synchronous HTTP requests. It's simple and widely used.
Q9
What does the Field(alias='..') parameter in Pydantic do?
✅ Correct! Field(alias='capitalInfo') maps capitalInfo from the API to capital_info in Python, following Python naming conventions.
Q10
What is the purpose of asyncio.gather()?
✅ Correct! asyncio.gather() runs multiple coroutines concurrently and returns their results. It's essential for parallel API calls.
Q11
Which Python 3.12+ feature allows you to create generic type aliases using a new syntax?
✅ Correct! Python 3.12 introduced the type keyword for creating type aliases: type Vector = list[float]
Q12
What does JSON stand for?
✅ Correct! JSON stands for JavaScript Object Notation. It's a lightweight data interchange format used extensively in APIs.
Q13
What HTTP status code indicates a successful request?
✅ Correct! HTTP 200 OK indicates a successful request. Other codes: 404 (not found), 500 (server error), 301 (redirect).
Q14
Which method is used to parse JSON data in Python?
✅ Correct! json.loads() parses a JSON string, and response.json() is a convenience method in requests.
Q15
What library would you use for numerical computing and working with arrays in Python?
✅ Correct! NumPy provides support for large, multi-dimensional arrays and matrices, along with mathematical functions. It's fundamental for AI development.
Q16
What is the recommended way to handle sensitive data like API keys in Python applications?
✅ Correct! Always store sensitive data in a .env file (not tracked by git) and load it with python-dotenv. Never hardcode API keys!
Q17
Which context manager ensures an aiohttp ClientSession is properly closed?
✅ Correct! async with aiohttp.ClientSession() as session: ensures the session is properly closed, even if errors occur.
Q18
What is the file extension for Python files?
✅ Correct! Python files use the .py extension.
Q19
Which exception should you catch when handling aiohttp request errors?
✅ Correct! aiohttp.ClientError is the base exception for all aiohttp client errors. You can also catch more specific errors like ClientConnectionError.
Q20
What is the primary benefit of using async programming for AI applications?
✅ Correct! Async programming allows you to make multiple AI API calls concurrently without blocking. This dramatically improves performance when working with LLMs.

Quiz Complete!

0%

← Back to Module 1 Next: Module 2 →