Docsity

Artificial Intelligence Programming Ultimate Exam, Exams of Technology

Toggle sidebar
bg1
Artificial Intelligence Programming
Ultimate Exam
**Question 1. Which Python feature allows automatic release of memory for
objects that are no longer referenced?**
A) __del__ method
B) Reference counting
C) Global Interpreter Lock
D) List comprehension
Answer: B
Explanation: Python’s garbage collector primarily relies on reference
counting; when an object’s reference count drops to zero, its memory is
reclaimed automatically.
**Question 2. In asyncio, which keyword is used to pause a coroutine until
the awaited Future is complete?**
A) yield
B) wait
C) async
D) await
Answer: D
Explanation: The `await` keyword suspends the coroutine, allowing the event
loop to run other tasks until the awaited Future resolves.
**Question 3. What does the `@wraps` decorator from `functools` preserve
when creating a decorator?**
A) Memory allocation
B) Original function’s signature and docstring
C) Thread safety
D) Global variables
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39

Partial preview of the text

Download Artificial Intelligence Programming Ultimate Exam and more Exams Technology in PDF only on Docsity!

Ultimate Exam

Question 1. Which Python feature allows automatic release of memory for objects that are no longer referenced? A) del method B) Reference counting C) Global Interpreter Lock D) List comprehension Answer: B Explanation: Python’s garbage collector primarily relies on reference counting; when an object’s reference count drops to zero, its memory is reclaimed automatically. Question 2. In asyncio, which keyword is used to pause a coroutine until the awaited Future is complete? A) yield B) wait C) async D) await Answer: D Explanation: The await keyword suspends the coroutine, allowing the event loop to run other tasks until the awaited Future resolves. Question 3. What does the @wraps decorator from functools preserve when creating a decorator? A) Memory allocation B) Original function’s signature and docstring C) Thread safety D) Global variables

Ultimate Exam

Answer: B Explanation: @wraps copies the wrapped function’s metadata (name, docstring, annotations) to the wrapper function, aiding debugging and introspection. Question 4. Which Pydantic feature validates that a field contains a URL string? A) conint B) HttpUrl C) StrictStr D) Field(default=…) Answer: B Explanation: HttpUrl is a Pydantic type that ensures the supplied string conforms to a valid HTTP/HTTPS URL format. Question 5. In linear algebra, the singular value decomposition of a matrix A = UΣVᵀ, what does Σ contain? A) Eigenvectors of A B) Orthogonal vectors of U C) Non-negative singular values on its diagonal D) Inverse of A Answer: C Explanation: Σ is a diagonal matrix whose entries are the non-negative singular values, representing the magnitude of each principal component. Question 6. Which operation computes the gradient of a scalar loss with respect to model parameters in a deep learning framework? A) Forward propagation

Ultimate Exam

Question 9. Which type of Markov chain has the property that the transition probabilities are time-independent? A) Non-homogeneous Markov chain B) Absorbing Markov chain C) Homogeneous Markov chain D) Reversible Markov chain Answer: C Explanation: In a homogeneous Markov chain, the transition matrix does not change over time, making the process stationary. Question 10. In NumPy, which operation enables element-wise addition without explicit Python loops? A) np.add.reduce() B) np.vectorize() C) Broadcasting with + operator D) np.apply_along_axis() Answer: C Explanation: NumPy’s broadcasting mechanism automatically expands smaller arrays to match shapes, allowing fast element-wise addition using +. Question 11. Which Pandas method returns a DataFrame with only the rows that have no missing values? A) df.fillna() B) df.dropna() C) df.isnull() D) df.replace() Answer: B

Ultimate Exam

Explanation: dropna() removes any rows (or columns) containing NaN values, yielding a clean DataFrame. Question 12. In Plotly, which parameter of go.Figure controls the interactivity of hover tooltips? A) hoverinfo B) mode C) layout.title D) showlegend Answer: A Explanation: hoverinfo (or hovertemplate) determines what information appears when a user hovers over a plot element. Question 13. Which search algorithm guarantees optimality if the heuristic is admissible and consistent? A) Greedy Best-First Search B) Depth-First Search C) A* Search D) Beam Search Answer: C Explanation: A* expands nodes based on f(n)=g(n)+h(n); with an admissible, consistent heuristic, it always finds the lowest-cost path. Question 14. In IDA (Iterative Deepening A), what is the primary purpose of the cost bound parameter?** A) Limit recursion depth B) Restrict memory usage C) Define the maximum f-cost for the current iteration

Ultimate Exam

Question 17. Which logic system allows quantification over variables, such as “for all x” and “there exists y”? A) Propositional logic B) First-order logic C) Modal logic D) Fuzzy logic Answer: B Explanation: First-order logic extends propositional logic with quantifiers (∀, ∃) and predicates that can take arguments. Question 18. In the Semantic Web, which RDF serialization format is most human-readable? A) Turtle B) N-Triples C) RDF/XML D) JSON-LD Answer: A Explanation: Turtle (Terse RDF Triple Language) provides a compact, line-oriented syntax that is easier for humans to read than RDF/XML. Question 19. Which planning representation encodes actions as preconditions and effects using a set of logical literals? A) PDDL (Planning Domain Definition Language) B) STRIPS C) HTN (Hierarchical Task Network) D) SATPlan Answer: B

Ultimate Exam

Explanation: STRIPS formalism represents actions by listing required preconditions and resulting add/delete effects. Question 20. In a Constraint Satisfaction Problem, which algorithm enforces arc consistency? A) Min-conflicts B) AC- 3 C) Forward checking D) Backjumping Answer: B Explanation: AC-3 iteratively removes values from variable domains that are inconsistent with binary constraints, achieving arc consistency. Question 21. Which regression model includes a penalty proportional to the sum of absolute coefficients? A) Ridge Regression B) Lasso Regression C) Elastic Net D) Polynomial Regression Answer: B Explanation: Lasso adds an L1 regularization term (λ∑|β_i|) that can shrink some coefficients exactly to zero, performing feature selection. Question 22. In Support Vector Machines, what does the kernel trick enable? A) Faster gradient descent B) Non-linear decision boundaries by implicitly mapping data to high-dimensional space

Ultimate Exam

**Question 25. Which clustering algorithm can discover arbitrarily shaped clusters and does not require specifying the number of clusters beforehand? ** A) K-Means++ B) DBSCAN C) Agglomerative Hierarchical Clustering D) Gaussian Mixture Models Answer: B Explanation: DBSCAN groups points based on density reachability, allowing detection of clusters of any shape and automatically labeling noise points. Question 26. In dimensionality reduction, which method preserves pairwise Euclidean distances as faithfully as possible in a lower-dimensional space? A) PCA B) t-SNE C) UMAP D) Multidimensional Scaling (MDS) Answer: D Explanation: Classical MDS aims to retain the original distance matrix, projecting points into fewer dimensions while minimizing stress. Question 27. Which anomaly detection technique models the data distribution using a mixture of Gaussians? A) One-Class SVM B) Isolation Forest C) Gaussian Mixture Model (GMM) D) Local Outlier Factor Answer: C

Ultimate Exam

Explanation: GMM fits multiple Gaussian components; points with low likelihood under the fitted mixture are flagged as anomalies. Question 28. Which cross-validation strategy is most appropriate for time-series data? A) K-Fold CV with random shuffling B) Stratified K-Fold C) Leave-One-Out CV D) Rolling-origin (walk-forward) validation Answer: D Explanation: Rolling-origin validation respects temporal order, training on past data and testing on future data, preventing leakage. Question 29. In hyperparameter optimization, what distinguishes Bayesian Optimization from grid search? A) It evaluates every possible combination B) It builds a probabilistic surrogate model to guide searches toward promising regions C) It uses random sampling only D) It requires no evaluation budget Answer: B Explanation: Bayesian Optimization models the performance surface (e.g., with a Gaussian Process) and selects hyperparameters that balance exploration and exploitation. Question 30. Which metric is insensitive to class imbalance and summarizes the trade-off between precision and recall? A) Accuracy

Ultimate Exam

Question 33. Which optimizer combines adaptive learning rates with momentum and includes weight decay directly in its update rule? A) Adam B) RMSprop C) AdamW D) SGD with Nesterov Answer: C Explanation: AdamW decouples weight decay from the adaptive moment estimates, applying L2 regularization directly after the parameter update. Question 34. The Nesterov Accelerated Gradient (NAG) differs from classical momentum by: A) Using a larger learning rate B) Computing the gradient at the “look-ahead” position before the update C) Ignoring past gradients D) Adding random noise to updates Answer: B Explanation: NAG first moves the parameters according to momentum, then evaluates the gradient at that projected point, leading to more responsive updates. Question 35. Which convolutional neural network architecture introduced residual connections to ease training of very deep networks? A) VGGNet B) ResNet C) Inception D) MobileNet Answer: B

Ultimate Exam

Explanation: ResNet adds identity shortcut connections, allowing gradients to flow directly and mitigating vanishing-gradient issues in deep models. Question 36. In Vision Transformers (ViT), how are image patches processed before feeding them to the transformer encoder? A) Flattened and linearly projected to a token embedding B) Convolved with a 3×3 kernel C) Passed through a recurrent layer D) Compressed using PCA Answer: A Explanation: ViT divides the image into fixed-size patches, flattens each patch, and applies a linear projection to obtain token embeddings analogous to word tokens. Question 37. Which object detection model predicts bounding boxes and class probabilities in a single forward pass without region proposals? A) Faster R-CNN B) YOLOv C) SSD (Single Shot MultiBox Detector) D) R-CNN Answer: B Explanation: YOLO (“You Only Look Once”) treats detection as a regression problem, outputting boxes and class scores directly from a single convolutional pass. Question 38. In semantic segmentation, which architecture combines encoder-decoder structure with skip connections to recover spatial detail? A) UNet B) ResNet- 50

Ultimate Exam

Question 41. Which attention variant computes attention weights between a query and a set of keys from a different modality? A) Self-attention B) Cross-attention C) Multi-head attention D) Local attention Answer: B Explanation: Cross-attention uses queries from one modality (e.g., text) and keys/values from another (e.g., image), enabling multimodal interaction. Question 42. What is the primary benefit of using multi-head attention instead of a single attention head? A) Reduces computational cost B) Allows the model to jointly attend to information from different representation subspaces C) Guarantees convergence D) Enforces sparsity in attention weights Answer: B Explanation: Multiple heads project inputs into different subspaces, each learning distinct patterns; concatenating them enriches the final representation. Question 43. In large language model pre-training, which objective predicts masked tokens while preserving bidirectional context? A) Causal language modeling (next-token prediction) B. Seq2Seq translation loss C) Masked Language Modeling (MLM) D) Contrastive loss

Ultimate Exam

Answer: C Explanation: MLM (used by BERT) randomly masks tokens and trains the model to predict them using both left and right context, enabling bidirectional understanding. Question 44. Reinforcement Learning from Human Feedback (RLHF) primarily uses which algorithm to align model outputs with human preferences? A) Proximal Policy Optimization (PPO) B) Q-Learning C) Monte Carlo Tree Search D) SARSA Answer: A Explanation: RLHF commonly employs PPO to fine-tune LLMs, optimizing a reward model derived from human preference data while maintaining stable updates. Question 45. Which tokenization method can represent any Unicode string without an out-of-vocabulary problem? A) Word-level tokenization B) Byte-Pair Encoding (BPE) C) SentencePiece Unigram D) Byte-Level BPE (e.g., GPT-2 tokenizer) Answer: D Explanation: Byte-Level BPE operates on raw bytes, guaranteeing that every possible string can be tokenized, eliminating OOV tokens. Question 46. In Retrieval-Augmented Generation (RAG), what is the role of the vector database?

Ultimate Exam

Explanation: ReAct interleaves reasoning (thought) with acting (tool usage), allowing the agent to invoke APIs, browse the web, or manipulate files as part of its answer generation. Question 49. Which library provides a high-level abstraction for chaining LLM calls, prompts, and tools into a single workflow? A) TensorFlow B) LangChain C) Scikit-learn D) PyTorch Lightning Answer: B Explanation: LangChain offers components like PromptTemplate, LLMChain, and Toolkits to compose complex LLM-driven pipelines. Question 50. Diffusion models generate images by iteratively: A) Upsampling a low-resolution grid B) Adding noise to a latent vector and then denoising it step-by-step C) Sampling from a GAN generator D) Using a transformer decoder Answer: B Explanation: Diffusion models start from pure Gaussian noise and apply a learned denoising network across many timesteps to produce a realistic image. Question 51. Which loss function is commonly used to train Variational Autoencoders? A) Mean Squared Error only B) Cross-entropy only

Ultimate Exam

C) Reconstruction loss + KL-divergence regularization D) Hinge loss Answer: C Explanation: VAE training balances reconstruction fidelity with a KL-divergence term that forces the latent distribution toward a prior (usually standard normal). Question 52. In GAN training, what is the purpose of the discriminator? A) Generate realistic samples B) Encode inputs into latent space C) Distinguish real from generated data, providing a learning signal to the generator D) Compute reconstruction loss Answer: C Explanation: The discriminator learns to classify real vs. fake samples; its gradients guide the generator to produce more plausible outputs. Question 53. Which container orchestration platform enables automatic scaling of AI inference services based on CPU/GPU utilization? A) Docker Compose B) Kubernetes C) Vagrant D) Ansible Answer: B Explanation: Kubernetes can monitor resource metrics and dynamically scale pods (including GPU-enabled ones) to match inference demand. Question 54. Quantizing a model to INT8 primarily reduces: