Semester exam level questions on introductory-level physics-oriented programming in Python for beginners.
TOPICS - Terminal, Shell, Bash, Scripts, Vim, Nano, Jupyter Notebook, functions and arguments, for and while loops, iterations and nested loops, continue, break, and pass control statements, i...
(Answer all questions -- do not spend more than 1 hour)
Each question carries 2 marks.
• A 1. Create a list of tuples containing the name and age of five imaginary friends .
• A2. Using (!) or otherwise, use a bash command to output the string , "This is a programming lab course!"
• A3. Define a recursive function for f (x) = x !, where X ! == I *2 * 3 * ... x and f (0) = 1. Print the output for f (10).
• A4. Using a single line statement, create a random 2 x 2 matrix A with elements between 0 and 5. You can include an additional import
statement.
• A5. Create a list from an array of 100 real numbers between 0 and 1. Extract the last five numbers.
• AG. Define a function that calculates the trace and determinant of a 2 x 2 matrix A, and returns a tuple at the output, i.e., output is (Tr(A) ,
det(A)).
Section 8
(Answer any 3 question -- do not spend more than 45 mins on each)
Each question carries 6 marks.
• 81. From linear algebra (and from elementary quantum mechanics), we know that all Hermitian matrices have real eigenvalues . However,
not all Hermitian matrices have positive eigenvalues (A; ~ 0, V i).
a) Write a function that checks if a random 2 x 2 matrix is Hermitian, both Hermitian and positive or neither. (3 Marks)
Hint: Use the numpy (as np) function np.round(x, 10) to round x to nearest 10 decimal points, and eliminate any small imaginary part that
remains due to numerical error. Moreover, the commands np.real and np.imag can be used to isolate real and imaginary parts. Use the
fact that for real eigenvalues, the imaginary part must be equal to 0.
Los beneficios de comprar resúmenes en Stuvia estan en línea:
Garantiza la calidad de los comentarios
Compradores de Stuvia evaluaron más de 700.000 resúmenes. Así estas seguro que compras los mejores documentos!
Compra fácil y rápido
Puedes pagar rápidamente y en una vez con iDeal, tarjeta de crédito o con tu crédito de Stuvia. Sin tener que hacerte miembro.
Enfócate en lo más importante
Tus compañeros escriben los resúmenes. Por eso tienes la seguridad que tienes un resumen actual y confiable.
Así llegas a la conclusión rapidamente!
Preguntas frecuentes
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
100% de satisfacción garantizada: ¿Cómo funciona?
Nuestra garantía de satisfacción le asegura que siempre encontrará un documento de estudio a tu medida. Tu rellenas un formulario y nuestro equipo de atención al cliente se encarga del resto.
Who am I buying this summary from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller RishabKumar. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy this summary for 2,91 €. You're not tied to anything after your purchase.