Test 1
Test 1
Instructions:
• You will have one hour and thirty minutes to complete the test from 08:50 – 10:20 AM
• This test consists of four questions.
• Each question has four sections, with each section worth 25% of the question's total points.
• The total test score is 100 points.
A) Define the three primary types of variables in Python and provide an example for each.
(6 points)
B) What error does Python return when you attempt to add a string and a float? Provide an example to
support your answer. (6 points)
C) Explain strong typing in Python with a brief code example demonstrating type conversion. (6
points)
D) Write a Python function to calculate the area and circumference of a circle. It should take the
circle's radius as input. (7 points)
A) Describe how to create a NumPy array in a Python. Give examples of creating a one-dimensional
and two-dimensional array. (6 points)
B) Explain the use of slicing in NumPy arrays with examples. Demonstrate how to:
Access elements from the second to the fourth in an array named sampleArray. (4 points)
Extract the first and third columns of a 2D array. (5 points)
C) How do you perform element-wise operations on NumPy arrays (addition, subtraction, etc.)?
Provide an example. (5 points)
D) Write a short function using NumPy to calculate the mean, standard deviation, and variance of a
dataset. (5 points)
A) Name five important libraries in Python for scientific computing and describe their uses. (5
points)
B) How do you import specific functions from libraries in Python? Provide examples using the sqrt
function from math. (5 points)
C) Write a Python function to determine the flow regime (laminar or turbulent) of a fluid in a pipe.
The function should take the fluid density, velocity, pipe diameter, and viscosity as inputs.
D) Use Matplotlib to create a scatter plot of vapor pressure vs. temperature using the provided
dataset: (5 points)