Questions DEPARTMENT OF CIVIL ENGINEERING
1. Store a list of prime numbers and print all primes below 50.
2. Create a tuple of the first 5 Fibonacci numbers and print them.
3. Store a dictionary mapping number names to their squares and
print the dictionary.
4. Append a new number to a list of integers and print the updated
list.
5. Create a list of angles in degrees and convert all to radians using
a loop.
6. Store a tuple of roots of a quadratic equation and print their sum
and product.
7. Create a dictionary with numbers as keys and their factorials as
values.
8. Remove duplicates from a list of integers and print the unique
elements.
9. Sort a list of integers in descending order and print the result.
10. Create a dictionary of math constants (pi, e, phi) and print their
values.
11. Store a list of tuples representing 2D points and find the point
closest to the origin.
12. Create a list of the first 10 even numbers using list
comprehension.
13. Store numbers and their squares in a dictionary and print keys
with squares > 50.
14. Given a list of numbers, count how many are prime.
15. Store coordinates of vertices of a polygon as tuples in a list and
print them.
16. Print the first 20 numbers in the Fibonacci sequence using a
loop.
17. Sum all integers from 1 to n, where n is input by the user.
18. Print all multiples of 7 between 1 and 100.
19. Loop through a list of numbers and print only the even ones.
20. Calculate the factorial of a number using a for loop.
21. Loop through numbers 1 to 100 and print "Fizz" if divisible by
3, "Buzz" if divisible by 5, and "FizzBuzz" if both.
22. Print all prime numbers between 1 and 100 using nested loops.
23. Loop through a list of angles in degrees and print their sine
values.
24. Calculate the sum of squares of numbers from 1 to n.
25. Print the multiplication table of a number input by the user.
26. Use a while loop to compute the greatest common divisor
(GCD) of two numbers.
27. Loop through a list of tuples representing points and print the
distance of each from the origin.
28. Print all palindromic numbers between 1 and 500.
29. Loop through a dictionary of numbers and their squares,
printing only those with squares divisible by 4.
30. Use a loop to approximate the value of π using the Leibniz
formula.
31. Read a file containing a list of numbers and calculate their
average.
32. Write a file listing the first 50 prime numbers.
33. Load a CSV file containing x and y coordinates and compute
the distance between each consecutive point.
34. Read a file of polynomial coefficients and evaluate the
polynomial at a given point.
35. Append a new data point to a text file containing function
values.
36. Write a function to save the results of a factorial calculation to
a file.
37. Read a file containing pairs of numbers and print those pairs
whose product is even.
38. Load data from a file and find the maximum and minimum
values.
39. Write a program that logs the output of sin(x) for x in 0 to 360
degrees to a file.
40. Read a file containing angles and convert all to radians, saving
results in a new file.
41. Read a CSV of numbers and count how many are perfect
squares.
42. Write a file that contains a multiplication table for numbers 1
to 10.
43. Read a file with polynomial roots and print their sum and
product.
44. Load a dataset of vector magnitudes and compute the average
magnitude.
45. Save a dictionary of mathematical constants to a JSON file.
46. Write a function to calculate the nth Fibonacci number
recursively.
47. Create a function that returns the factorial of a given number.
48. Write a function that checks if a number is prime.
49. Define a function that calculates the area of a circle given its
radius.
50. Create a function that returns the roots of a quadratic
equation given coefficients.
51. Write a function to convert degrees to radians.
52. Define a function that calculates the distance between two
points in 2D space.
53. Create a function to calculate the sum of a list of numbers.
54. Write a function that checks if a number is a palindrome.
55. Define a function to compute the GCD of two numbers using
Euclid’s algorithm.
56. Write a function that returns the list of divisors of a number.
57. Create a function that normalizes a list of numbers to a scale
between 0 and 1.
58. Write a function that calculates the nth triangular number.
59. Define a function that generates a list of prime numbers up
to n.
60. Write a function that calculates the nth Catalan number
using recursion
61. Create a Vector2D class with methods to add, subtract, and
compute magnitude.
62. Define a Matrix class with attributes for rows and columns
and a method to transpose.
63. Implement a Polynomial class with methods to evaluate at a
given point and find degree.
64. Create a ComplexNumber class with methods for addition,
subtraction, and modulus.
65. Write a Circle class with methods to compute area and
circumference.
66. Implement a Triangle class that checks if three side lengths
form a valid triangle and computes its area.
67. Create a Point class representing a 2D point with methods
to calculate distance to another point.
68. Define a Sequence class that stores a list of numbers and can
compute mean, median, and mode.
69. Implement a Matrix class with a method to multiply by
another matrix.
70. Write a FactorialCalculator class with a method that returns
factorial of a number.
71. Create a PrimeChecker class that stores a number and checks
if it is prime.
72. Define a Circle class that can check if a point lies inside the
circle.
73. Implement a QuadraticEquation class with methods to
calculate roots and vertex.
74. Write a NumberStats class that stores a list of numbers and
computes variance and standard deviation.
75. Create a FibonacciGenerator class that generates Fibonacci
numbers up to n.
76. Write a program using a loop to find the sum of the first n
natural numbers.
77. Use a loop to calculate the sum of the squares of the first n
natural numbers.
78. Print all prime numbers between 1 and 200 using a loop.
79. Generate the first n numbers in the arithmetic progression
with a given first term and common difference.
80. Use a loop to calculate the product of all odd numbers
between 1 and 50.
81. Print the multiplication table of a given number up to 12.
82. Find the sum of all multiples of 3 or 5 below 1000 using
loops.
83. Use a loop to find all perfect numbers up to 1000.
84. Print the first n terms of the geometric sequence with given
initial term and ratio.
85. Calculate the sum of digits of a number entered by the user
using a while loop.
86. Find the reverse of a number using loops.
87. Use nested loops to print a Pascal’s triangle of height n.
88. Calculate the factorial of a number using a while loop.
89. Print the Fibonacci series up to the nth term using a while
loop.
90. Using a loop, check if a number is a palindrome.
91. Write a program to find the greatest common divisor (GCD)
of two numbers using loops.
92. Print all Armstrong numbers between 100 and 999 using
loops.
93. Use loops to calculate the harmonic series sum up to n terms.
94. Write a program to approximate e (Euler’s number) using
the series expansion.
95. Use loops to calculate the sum of the first n cube numbers.
96. Generate the factorial values for numbers from 1 to n and
store them in a list.
97. Find the number of trailing zeros in n! using loops.
98. Write a program to find the first n Fibonacci numbers using
a for loop.
99. Use loops to calculate the value of sine(x) using Taylor
series approximation.
100. Using loops, find all divisors of a number and print them.
101. Find the least common multiple (LCM) of two numbers
using loops.
102. Write a program to print a pattern of stars in a pyramid shape
using nested loops.
103. Use a loop to print prime factorization of a given number.
104. Find the sum of all even Fibonacci numbers less than n using
loops.
105. Use nested loops to print a multiplication table from 1 to 10.
106. Find the nth triangular number using a loop.
107. Write a program to find the sum of digits of all numbers
from 1 to n using loops.
108. Calculate the product of the first n natural numbers
excluding multiples of 5 using loops.
109. Write a loop to compute the binomial coefficient “n choose
k” using factorial.
110. Use loops to find the maximum and minimum elements in a
given list of numbers.
111. Generate the Collatz sequence for a given number using
loops.
112. Use loops to compute the sum of an alternating harmonic
series.
113. Calculate the sum of the digits of the factorial of a number
using loops.
114. Print all narcissistic numbers up to 10000 using loops.
115. Write a program to simulate rolling two dice 1000 times and
count the occurrences of each sum using loops.
116. Write a program to read a file containing integers and
compute their mean and median.
117. Load a CSV file with columns representing x and y
coordinates and calculate the Euclidean distance between
consecutive points.
118. Write a function to save the first 100 Fibonacci numbers to
a text file.
119. Read a file of polynomial coefficients and evaluate the
polynomial for x = 5.
120. Write a program to append the squares of numbers from 1
to 50 into a text file.
121. Load a file containing numbers, remove duplicates, and
write the unique numbers to another file.
122. Write a program to read a file and find the standard deviation
of the numbers.
123. Read a CSV file containing matrix data and calculate its
transpose.
124. Write a program that reads data points from a file and fits a
linear regression line (y = mx + c).
125. Read a file containing numbers and plot a histogram of their
distribution using matplotlib (if allowed).
126. Write a program to save the prime numbers between 1 and
200 into a file.
127. Read a file with complex numbers in string format and
compute their average magnitude.
128. Write a program to read a CSV file and find the correlation
coefficient between two columns.
129. Load a file containing angle values and write their sine and
cosine values to another file.
130. Read a file with a list of integers and count how many are
even and odd.
131. Write a program that reads a file of decimal numbers and
rounds them to the nearest integer, saving the results.
132. Read a file of 2D points and calculate the perimeter of the
polygon they form.
133. Write a program that reads numbers from a file and outputs
the cumulative sum at each line.
134. Read a file of grades and calculate the grade distribution
percentage.
135. Write a program to read a file of numbers and find the
mode(s).
136. Write a program to merge two files containing sorted lists
of numbers into one sorted file.
137. Read a file containing numeric data and normalize it to a 0-
1 scale.
138. Write a program to count the frequency of each digit (0-9)
in a file containing numbers.
139. Load a CSV file containing the results of a quadratic
equation and identify rows where roots are complex.
140. Write a program to read a file of vectors and compute their
magnitudes.
141. Write a program to read a file and output the moving average
of numbers with a specified window size.
142. Read a file with numeric data and calculate the variance and
standard deviation.
143. Write a program to write the first n prime numbers to a CSV
file with their indices.
144. Read a file containing integer sequences and find the longest
increasing subsequence.
145. Write a program to read a file with polynomial coefficients
and output the roots to another file.
146. Read a CSV of numbers and calculate the geometric mean
for each row.
147. Write a program to read a file of 3D points and compute the
centroid of these points.
148. Write a program that reads a file of numbers and removes
all outliers beyond 3 standard deviations.
149. Load a file containing math function values and find the
maximum and minimum differences between consecutive
values.
150. Write a program to convert a CSV of Cartesian coordinates
to polar coordinates and save them.
151. Write a program to read a file of integers and calculate their
factorials, saving the results.
152. Read a file of numbers and calculate the cumulative product
of these numbers.
153. Write a program that reads a file with quadratic equation
coefficients and determines the number of real roots for each
line.
154. Read a file of integer pairs and calculate their pairwise sums
and products.
155. Write a program to generate a histogram from a file of
numeric data and save it as an image (if allowed).
156. Write a function that returns the nth prime number.
157. Create a function to compute the sum of the first n natural
numbers recursively.
158. Define a function to compute the binomial coefficient C(n, k).
159. Write a function to calculate the area of a regular polygon given
the number of sides and side length.
160. Create a function that returns True if a number is a perfect
square.
161. Write a function that computes the Taylor series approximation
of e^x up to n terms.
162. Define a function that computes the nth Catalan number.
163. Write a function to find the roots of a quadratic equation using
the quadratic formula.
164. Create a function that takes a list of numbers and returns the
standard deviation.
165. Write a function that computes the greatest common divisor
(GCD) using recursion.
166. Define a function that generates the Collatz sequence for a
number and returns it as a list.
167. Write a function that returns True if a number is a palindrome.
168. Create a function to calculate the nth harmonic number.
169. Define a function to calculate the volume of a sphere given its
radius.
170. Write a function that computes the first n Fibonacci numbers
and returns them as a list.
171. Create a function to check if two matrices can be multiplied.
172. Define a function that returns the factorial of a number using
memoization.
173. Write a function that converts Cartesian coordinates to polar
coordinates.
174. Create a function to calculate the mean absolute deviation of a
list of numbers.
175. Write a function that performs linear interpolation between two
points.
176. Define a Vector class that supports addition, subtraction, and
dot product.
177. Implement a Matrix class with methods for addition,
multiplication, and transpose.
178. Create a Polynomial class with methods to evaluate, add,
and multiply polynomials.
179. Define a Circle class with attributes radius and center, and
methods for area, circumference, and point containment.
180. Implement a Triangle class that validates side lengths and
computes the area and perimeter.
181. Write a ComplexNumber class with methods for addition,
subtraction, multiplication, and magnitude.
182. Create a Point class with methods to calculate distance to
another point.
183. Implement a Sequence class that holds a list of numbers and
computes mean, median, mode, and variance.
184. Define a Fibonacci class that generates Fibonacci numbers
up to n.
185. Write a Factorial class that computes factorials using
memoization.
186. Implement a Matrix class with a method to check if it is
symmetric.
187. Create a NumberProperties class that can check if a number
is prime, perfect, or a palindrome.
188. Define a QuadraticEquation class that calculates roots,
discriminant, and vertex.
189. Implement a Statistics class to compute mean, median,
mode, variance, and standard deviation from a data set.
190. Write a Polygon class that computes perimeter and area
given vertices.
191. Create a Line class with methods to find slope, intercept,
and check parallelism with another line.
192. Define a MatrixOperations class that implements matrix
193. A car travels a distance of 150 km in 2.5 hours. Store these
values in variables distance and time. Calculate and print the
average speed in m/s.
194. Calculate and print the potential energy of a 10 kg mass at 5
meters.
195. An experiment requires the temperature to be between 20°C
and 25°C (inclusive), and the humidity to be below 60%. Ask
the user for temperature and humidity. Print True if conditions
are met, False otherwise.
196. Ask the user for a measured value (e.g., 10.5) and its unit (e.g.,
"meters"). Print a formatted string like "Measurement: 10.5
meters".
197. Ask the user for a force value (e.g., "50") and a mass value (e.g.,
"10"). Convert them to the appropriate numerical types and
calculate acceleration. Print the result.
198. Ask the user for the temperature of water in Celsius. Print
"Solid" if temperature is ≤0, "Liquid" if between 0 and 100
(exclusive), and "Gas" if ≥100.
199. A student takes 5 measurements of a pendulum's period. Store
these in a list. Use a for loop to print each measurement.
200. Simulate an iterative process that stops when a value is below
a certain threshold. E.g., start value = 100 and threshold = 10.
In each iteration, the value halves. Count how many iterations
it takes to reach the threshold.
201. A sensor ID is "SENSOR-XYZ-TEMP-001". Extract and print
only the part representing the sensor type (e.g., "TEMP").
202. Store a very small number (e.g., electron charge =
1.602176634e-19). Print it using f-strings formatted to 2
decimal places in scientific notation.
203. Create two lists for current and voltage. Calculate the resistance
using Ohm’s law.
204. Start with temperatures = [20.5, 21.0]. Ask the user to input
three new temperature readings. Add them to the list and print
the updated list.
205. Given current_readings = [0.5, 0.7, 0.4, 0.9, 0.6], find and print
the highest and lowest current readings.
206. Create a list of velocities, use list comprehension to create
a new list containing the kinetic energy (per unit mass, so
0.5×v2) for each velocity.
207. Represent a 2D position as a tuple (x, y). Create two such
tuples. Calculate and print the distance between them.
208. An experiment recorded (time, temperature, pressure) as a
tuple. Create a few such tuples and store them in a list. Access
and print the temperature of the second reading.
209. Create a dictionary physical_constants = {'g': 9.81, 'pi':
3.14159, 'c': 299792458}. Ask the user for a constant symbol
(e.g., 'g') and print its value.
210. A dictionary sensor_data = {'temperature': 22.5, 'humidity':
65}. Update the temperature to 23.1 and add a new entry
pressure: 1012.5. Print the updated dictionary.
211. A dictionary experiment_log = {'Trial1': {'time': 10,
'result': 5.2}, 'Trial2': {'time': 12, 'result': 6.1}}. Iterate through
the dictionary and print the result for each trial.
212. Create a dictionary materials = {'steel': {'density': 7850,
'elasticity': 200e9}, 'aluminum': {'density': 2700, 'elasticity':
70e9}}. Ask the user for a material name and print its density.
213. Function: Kinetic Energy: Write a function
calculate_kinetic_energy(mass, velocity) that takes mass (kg)
and velocity (m/s) and returns kinetic energy (KE=0.5×m×v2).
Test with various values.
214. Write a function calculate_power(work, time) that returns
power. Handle the case where time is zero to avoid division by
zero.
215. Write a function celsius_to_fahrenheit(celsius) that
converts Celsius to Fahrenheit. Get Celsius input from the user
and print the Fahrenheit equivalent.
216. Write a function add_vectors(v1, v2) that takes two 2D
vectors (each as a tuple (x, y)) and returns their sum as a new
tuple.
217. Create a class Particle with attributes mass and velocity.
Add a method calculate_momentum() that returns mass *
velocity. Instantiate a particle and print its momentum.
218. Create a class Resistor with an attribute resistance (Ohms).
Add methods get_voltage(current) that returns voltage (V=IR)
and get_current(voltage) that returns current (I=V/R).
219. Create a class Vehicle with attributes distance and time.
Add a method get_velocity(velocity) that returns the velocity of
the vehicle.
220. Write a function calculate_work_done(force,
displacement, angle_degrees) that calculates work done
(W=F⋅d⋅cos(θ)). Use math.cos and convert angle to radians.
221. Create a class DataLogger that can store a list of
(timestamp, value) tuples. Add methods add_reading(timestamp,
value) and get_average_value().
222. Write a function get_average_velocity(position_data)
where position_data is a list of (time, position) tuples. The
function should calculate the average velocity between the first
and last data points.
223. Simulate sensor readings. Start with readings = [10, 12, 15,
18, 22, 25, 20]. Use a for loop to iterate through the readings
and break once a reading exceeds 20. Print the readings
processed before the break.
224. Simulate an experiment that requires specific conditions. If
a certain condition (e.g., temp < 50) is met throughout all steps,
print "Experiment completed successfully". Use for...else.
225. Ask the user for two integers. Print their sum, difference,
product, and integer division result.
226. Ask the user for a numerator and a denominator. Perform
float division and print the result, clearly indicating if the
denominator was zero.
227. Ask the user for an integer. Print True if the number is
positive AND even, False otherwise.
228. Ask the user for a, b, and c for a quadratic equation. Print
the equation in the form "ax2+bx+c=0" using an f-string.
229. Ask the user to input a sequence of numbers separated by
commas (e.g., "10,20,30.5"). Convert each number to its
appropriate type (int or float) and store them in a list.
230. Ask the user for a number. Print "Positive", "Negative", or
"Zero".
231. Use a for loop to calculate the sum of all integers from 1 to
50. Print the sum.
232. Write a while loop that counts down from 5 to 1, printing
each number, then prints "Start!".
233. Ask the user for a string. Use isdigit() to check if the string
contains only digits. Print "All digits" or "Contains non-digits".
234. Given total_students = 150 and passed_students = 120.
Calculate the pass percentage and print it formatted to two
decimal places (e.g., "Pass rate: 80.00%").
235. Create a list of test scores scores = [78, 85, 92, 65, 70].
Calculate and print the average score.
236. Start with a list of grades grades = ['A', 'B', 'C', 'B', 'A']. If
a specific grade (e.g., 'C') exists, change it to 'C+'. Print the
updated list.
237. Use a for loop and range() to create a list of numbers from
0 to 20, where only multiples of 3 are included.
238. Use list comprehension to create a list containing the cubes
of numbers from 1 to 7.
239. Represent a point in 3D space as a tuple (x, y, z). Create
two such points and calculate the midpoint between them.
240. Represent the coefficients of a quadratic equation ax^2 +
bx + c as a tuple (a, b, c). Ask the user for coefficients and store
them in a tuple.
241. Create a dictionary formulas = {'area_circle': 'pi * r**2',
'perimeter_square': '4 * side'}. Ask the user for a formula name
and print its expression.
242. A dictionary student_scores = {'Alice': 88, 'Bob': 75}. Add
a new student 'Charlie' with a score of 90. Update Bob's score to
80. Print the dictionary.
243. Given a dictionary grade_counts = {'A': 15, 'B': 20, 'C': 10,
'D': 5, 'F': 2}. Calculate and print the total number of students.
244. Create a 2x2 matrix as a nested list. Calculate and print the
sum of all elements in the matrix.
245. Write a function calculate_factorial(n) that takes an integer
n and returns its factorial. Handle the base case (0!=1) and
negative numbers.
246. Write a function is_prime(number) that returns True if the
number is prime, False otherwise. Test it with numbers like 7,
10, 23.
247. Write a function calculate_rectangle_area(length, width)
with default values for length and width if not provided. Test
both scenarios.
248. Write a function solve_quadratic(a, b, c) that takes
coefficients a, b, c and returns the two roots of the quadratic
equation. Handle cases for real and complex roots (return None
or a string message for complex roots).
249. Create a class Point with x and y attributes. Add a method
distance_from_origin() that calculates the distance from (0,0).
250. Calculator: Create a class Calculator with methods add(a,
b), subtract(a, b), multiply(a, b), and divide(a, b). Instantiate the
class and perform several operations.
251. Create a class Triangle with attributes length and height.
Add a method area(), calculating the area of the triangle.
252. Write a function generate_fibonacci(n) that returns a list
containing the first n Fibonacci numbers.
253. Create a class Polynomial that stores coefficients as a list
(e.g., [c0, c1, c2] for c0+c1x+c2x2). Add a method evaluate(x)
that calculates the polynomial value at a given x.
254. Write a function sum_arithmetic_series(a1, n, d) that
calculates the sum of an arithmetic series (Sn=2n(2a1+(n−1)d)).
255. Print odd numbers from 1 to 20 using a for loop and the
continue statement to skip even numbers.
256. Implement a simple counter for how many times a specific
mathematical function (e.g., square_root calculation) is called.
Use a global variable.
257. Write a Python function to calculate the density of a
material given mass and volume.
258. Create a function that returns the average atomic weight
from a list of atomic weights.
259. Define a function to calculate stress from force and area.
260. Create a function that takes a list of material names and
returns those with more than 8 characters.
261. Write a function to compute the Young's modulus from
stress and strain values.
262. Make a function that returns the highest thermal
conductivity from a list.
263. Define a function to calculate the molar mass of a
compound (given a list of element masses).
264. Write a function that filters out non-metals from a list of
materials.
265. Write a function that accepts a list of hardness values and
returns their median.
266. Create a function to calculate the fracture toughness based
on input values.
267. Write a function to calculate porosity using initial and final
volume.
268. Define a function to find the total number of atoms in a
sample from a list of atom counts.
269. Write a function that accepts a material and returns
whether it is ductile or brittle.
270. Write a function to simulate heat capacity at constant
pressure using user-defined data.
271. Create a list of 10 metal elements and print the first five.
272. Use NumPy to create an array of temperatures in Celsius
and convert all to Kelvin.
273. Create a list of atomic radii and calculate the average using
NumPy.
274. Create a list of crystal structures and sort them
alphabetically.
275. Create a 2D NumPy array representing lattice parameters
and print its shape.
276. Use a list to store the names of polymers and remove
duplicates.
277. Make a NumPy array of stress values and apply a scalar
multiplication.
278. Slice a list of grain sizes to display only the values
between 20 and 50 µm.
279. Replace negative values (defects) in a NumPy array of
stress with 0.
280. Use NumPy to find the max and min from a list of thermal
conductivity values.
281. Create a list of phase transition temperatures and count
how many are below room temp.
282. Create a NumPy array to simulate thermal expansion over
a temperature range.
283. Use a list of atomic numbers and find all that are divisible
by 2.
284. Store elastic modulus values in a list and filter those above
200 GPa.
285. Create a NumPy array of Poisson’s ratio and compute its
mean.
286. Create a class Material with properties: name, density, and
thermal conductivity.
287. Write a class method to display all attributes of a Material
object.
288. Create a class Alloy that inherits from Material and adds a
list of components.
289. Add a method in Material class to calculate mass from
density and volume.
290. Create a Polymer class with properties like molecular
weight and glass transition temp.
291. Write a constructor for the Material class that prints a
message when an object is created.
292. Use class objects to store 5 materials and print their
densities.
293. Create a method in Alloy class to add a new metal
component.
294. Create a Composite class with list properties for matrix
and reinforcement.
295. Add a method in
296. Create a Material class with properties like name, density,
and melting_point. Instantiate it for copper.
297. Add a method to the Material class to check if the material
is a metal (use a boolean attribute).
298. Create a class Composite that holds a list of materials and
their volume fractions.
299. Add a method in Material class to compute mass given
volume.
300. Define a Crystal_Structure class with attributes:
lattice_type, lattice_constant.
301. Write a method in the Crystal_Structure class that
calculates unit cell volume.
302. Implement a class Alloy with a method to compute
average melting point from component materials.
303. Create a Sample class to store stress and strain data and
calculate Young’s modulus.
304. Build a class Test_Specimen with attributes like shape,
dimensions, and a method to compute surface area.
305. Create a class Thermal_Material with a method to
calculate heat flow using Fourier’s law.
306. Use NumPy to store thermal conductivity values of 10
materials. Find the material with the highest value.
307. Given a NumPy array of atomic radii, calculate the
average radius.
308. Create a 2D NumPy array representing stress values in
different directions and calculate principal stress.
309. Use NumPy to generate a temperature profile along a
metal rod and compute the gradient.
310. Store and reshape a NumPy array representing crystal
plane spacing in a cubic lattice.
311. Simulate thermal expansion by applying a scale factor to
an array of initial lengths using NumPy.
312. Use NumPy to add noise to experimental data (e.g., stress-
strain values).
313. Use NumPy to compute element-wise product of two
arrays representing heat capacity and temperature rise.
314. Create a list of 10 materials and print only those with a
melting point above 1000°C.
315. Given a list of densities, find the material with the lowest
density.
316. Store a list of defects in a material (e.g., voids,
dislocations) and remove duplicates.
317. Create a list of tuples containing (material name, thermal
conductivity) and sort by conductivity.
318. Count how many times “Aluminum” appears in a list of
sample materials.
319. Create a list of grain sizes and filter out those greater than
50 micrometers.
320. Merge two lists: one with material names and one with
their tensile strengths.
321. Write a program that loops through a list of materials and
prints a warning if a hazardous material is detected.
322. Calculate the total mass of an aircra4 given its empty
weight (40,000 kg), fuel mass (15,000 kg), and payload mass
(8,000 kg). Store these values in variables, then compute the
total mass and print the result, including units.
323. Calculate the thrust-to-weight raGo for a rocket. Ask the
user to input the total_thrust (in Newtons) and the iniGal_mass
(in kg). Assume standard gravity g = 9.81 m/s^2. Compute the
weight (W=m×g) and then the thrust-to-weight raGo, prinGng
the result formaQed to two decimal places.
324. Convert an alGtude reading from feet to meters. Store the
alGtude in feet as alGtude_4 = 35000.0. Convert it to meters (1
foot = 0.3048 meters) and print both the original feet and the
calculated meters alGtudes.
325. Determine if an aircra4 is ready for flight. It's ready if the
fuel tanks are full (True) AND the weather is clear (True). Given
fuel_full = True and weather_clear = False, create a boolean
variable flight_ready reflecGng both condiGons and print its
value.
326. Process an aircra4's tail number, "N123ABC". Store this ID
in a string variable tail_number. Print the tail_number and then
print the total number of characters (its length).
327. Classify the flight phase of an aircra4 based on its alGtude
and speed. Ask the user for alGtude (in meters) and speed (in
m/s). Print "Takeoff/Landing" if alGtude < 100 and speed < 100.
Print "Cruising" if alGtude >= 5000 and speed >= 200.
Otherwise, print "Climb/Descent or Maneuvering".
328. Determine an engine's status based on RPM and
temperature. Ask the user for engine_rpm and engine_temp_c.
Print "Engine OFF" if engine_rpm == 0. Print "Engine IDLE" if
engine_rpm > 0 and engine_rpm < 500. Print "Engine
OPERATIONAL" if engine_rpm >= 500 and engine_temp_c <
1000. Otherwise, print "Engine OVERHEAT/CRITICAL".
329. Classify the atmospheric layer based on alGtude. Ask the
user for alGtude_km. Print "Troposphere" if alGtude_km <= 12.
Print "Stratosphere" if alGtude_km > 12 and alGtude_km <= 50.
Print "Mesosphere" if alGtude_km > 50 and alGtude_km <= 85.
Otherwise, print "Thermosphere".
330. Determine if landing gear is ready for deployment. It's
ready if the aircra4 speed is below 150 knots AND the alGtude
is below 1000 feet. Ask the user for speed_knots and
alGtude_feet. Use logical operators (and) to print "Landing gear
deployable." or "Landing gear NOT deployable."
331. Verify the integrity of a pitot-staGc system based on
pressure readings. Ask for pitot_pressure (stagnaGon pressure)
and staGc_pressure (ambient pressure). Use nested if
statements.
332. Access specific elements from a list of airspeed readings.
Given airspeed_readings = [120, 150, 180, 200, 210] knots, print
the second reading (index 1) and the second to last reading
(using negaGve indexing).
333. Add new alGtude measurements to an exisGng flight data
log. Start with alGtude_log = [1000, 2500, 5000]. Use the
append() method to add 7500 and 10000 meters to the end of
the list. Print the updated alGtude_log list.
334. Remove an obviously incorrect sensor reading from a data
list. Given sensor_data = [9.8, 10.1, -999.0, 9.9, 10.0] m/s$^2$,
where -999.0 is an erroneous reading. Use the remove()
method to delete it and print the cleaned list.
335. Print each aircra4 type along with a sequenGal number.
Given aircra4_types = ["Boeing 737", "Airbus A320", "Embraer
E190", "Cessna 172"], use a for loop with enumerate() to print a
message like: "Aircra4 1: Boeing 737".
336. IdenGfy the highest and lowest engine thrust values from
a test run. Given thrust_readings = [10000, 12500, 8000, 15000,
11000] N, use built-in max() and min() funcGons to find and
print the maximum and minimum thrust values.
337. Organize a list of aerodynamic drag coefficients. Given
drag_coefficients = [0.035, 0.028, 0.041, 0.030] (dimensionless),
use the sort() method to sort the list in ascending order and
print it. Then, sort it in descending order (using reverse=True)
and print again.
338. Quickly calculate the dynamic pressure for a series of
airspeeds at a constant density. Given airspeeds = [50, 75, 100,
125] m/s and air_density = 1.225 kg/m$^3$, use list
comprehension to create a new list dynamic_pressures with the
calculated values (Q=0.5×ρ×v2). Print dynamic_pressures.
339. Represent and access 3D coordinates for points along a
flight path. Create a nested list: flight_path = [[0, 0, 0], [1000,
500, 100], [2000, 1200, 250]] (X, Y, AlGtude in meters). Access
and print the alGtude of the second point (index 1, third
element).
340. Extract and use registraGon details of an aircra4.
Represent registraGon as aircra4_reg = ("N12345", "Boeing
747", "Cargo"). Unpack this tuple into separate variables
tail_number, model, and type. Print each variable.
341. Define a fixed set of 3D waypoint coordinates that should
not be changed during a mission. Define waypoint1 = (10.0,
20.0, 5.0) (laGtude, longitude, alGtude). Briefly explain in a
comment why a tuple is more suitable than a list for
represenGng these immutable coordinates.
342. Store mulGple sensor readings, each with a Gmestamp.
Create a tuple of tuples engine_readings = (("08:00", 950),
("08:05", 955), ("08:10", 960)) (Gmestamp, RPM). Use a for loop
to iterate. In each iteraGon, unpack the inner tuple directly into
Gme and rpm variables, then print each reading's Gme and rpm.
343. Create a funcGon to calculate li4 and drag forces. Write a
funcGon calculate_aero_forces(cl, cd, q, S) that takes the
coefficient of li4 (CL), coefficient of drag (CD), the dynamic
pressure (Q), and reference area (S) as arguments. It should
return li4 (L=CLQS) and drag (D=CDQS) as a tuple. Call with
example values (e.g., CL=0.5, CD=0.03, Q=1000, S=10) and print
both forces.
344. Query a log of aircra4 fault codes for specific occurrences.
Given fault_log = ('ENG-001', 'NAV-002', 'ENG-001', 'HYD-003',
'NAV-002', 'FCS-004'), use the count() method to find how many
Gmes 'ENG-001' appears. Use the index() method to find the
index of the first occurrence of 'HYD-003'. Print both results.
345. Ensure a user-selected runway is from a predefined list of
valid opGons. Define valid_runways = ('09L', '09R', '27L', '27R').
Ask the user for a runway_choice. Use the in operator to check
for its presence and print "Valid runway selected" or "Invalid
runway selected".
346. "Freeze" a list of flight plan waypoints to prevent further
modificaGons a4er iniGal planning. Given flight_plan_mutable =
['KSFO', 'KDEN', 'KJFK'], convert this list to a tuple named
flight_plan_immutable. Print the flight_plan_immutable tuple.
347. Retrieve the number of available aircra4 of a specific type.
Create a dicGonary fleet_inventory = {'Boeing 737': 15, 'Airbus
A320': 20, 'Embraer E190': 8}. Print the quanGty of 'Airbus
A320' by accessing its value.
348. Update the status of an aircra4 in a maintenance log and
add a new aircra4. From the fleet_inventory dicGonary (from
Q26), add 'Cessna 172' with 5. Then, update 'Boeing 737'
quanGty to 14 (one taken for maintenance). Print the updated
fleet_inventory dicGonary.
349. Remove a decommissioned aircra4 type from the fleet
inventory. From the fleet_inventory dicGonary (from Q27),
remove the entry for 'Embraer E190'. Print the dicGonary a4er
removal.
350. List all aircra4 models and then their quanGGes separately
from the fleet inventory. Using the fleet_inventory dicGonary
(a4er Q28), use a for loop to print only the aircra4 models
(keys). Use another for loop to print only the quanGGes
(values).
351. Access specific performance parameters from a database
of aircra4 types. Create aircra4_performance = {'B737':
{'max_speed': 0.82, 'range_km': 5765}, 'A320': {'max_speed':
0.8, 'range_km': 6100}}. Access and print the range_km of
'A320'.
352. Verify if an aircra4 model exists in the performance
database before aQempGng to retrieve its specificaGons. Ask
the user for a search_model. Check if this model exists as a key
in the aircra4_performance dicGonary (from Q30). Print "Model
found!" or "Model not found!".
353. Gracefully retrieve opGonal aircra4 specificaGons without
errors if they are missing. From aircra4_performance (from
Q30), try to retrieve the ceiling_4 for 'B737' using the get()
method, providing "N/A" as a default if not found. Print the
retrieved value. Then, retrieve and print the max_speed for
'B737'.
354. Generate a report lisGng both the aircra4 model and its
quanGty from the fleet. Using the fleet_inventory dicGonary
{'Boeing 737': 14, 'Airbus A320': 20, 'Cessna 172': 5}, use a for
loop with the .items() method to print a message like: "Model:
Boeing 737, QuanGty: 14" for each item.
355. IdenGfy all unique materials used in a prototype aircra4
from a list that may contain duplicates. Given materials_list =
['Aluminum', 'Titanium', 'Carbon Fiber', 'Aluminum', 'Steel',
'Carbon Fiber'], create a set named unique_materials from this
list. Print the set.
356. Determine if a specific cerGficaGon is held by an
aerospace company. Given company_cerGficaGons = {'ISO
9001', 'AS9100', 'EASA Part 145'}, ask the user to input a
cerGficaGon_to_check. Use the in operator to check its
presence in the set and print "CerGficaGon held." or
"CerGficaGon not held."
357. Find common skills between required project skills and
available team skills. Given required_skills = {'Aerodynamics',
'Structures', 'Propulsion', 'Avionics'} and team_skills =
{'Structures', 'Manufacturing', 'Aerodynamics', 'CAD Design'},
use the set intersecGon operator (&) to find and print the skills
common to both sets.
358. Combine flight plan deviaGons reported by two different
sources to get a comprehensive list. Given source_a_deviaGons
= {'Weather Reroute', 'Air Traffic Control', 'Mechanical Issue'}
and source_b_deviaGons = {'Mechanical Issue', 'Pilot Error',
'Weather Reroute'}, use the set union operator (|) to find and
print all unique deviaGons.
359. Create a class KinemaGcs with aQributes: iniGal_velocity,
acceleraGon, and Gme. Add a method to calculate final velocity.
360. Create a class SimplePendulum that calculates the time
period using the formula T = 2π√(L/g).
361. Write a program to record speed and acceleration data and
plot a basic velocity-time graph.
362. Write a Python script to save radioactive decay data at
regular intervals in a CSV file.
363. Write a program that reads wave parameters (frequency,
wavelength) from a file and calculates speed.
364. Create a log file that records all inputs and outputs of an
OhmLaw() function each time it is called.
365. Write a script that stores calculated kinetic and potential
energies for a set of objects into a file.