100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Other

Python Programming Mock Papers

Rating
-
Sold
-
Pages
6
Uploaded on
07-05-2023
Written in
2022/2023

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, if, else, and elif conditional statements, nested statements, recursion, random numbers, Numpy, linalg, matplotlib, Scipy, integrate, solve_ivp, dictionary, pandas.

Show more Read less
Institution
Course








Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Course

Document information

Uploaded on
May 7, 2023
Number of pages
6
Written in
2022/2023
Type
Other
Person
Unknown

Subjects

Content preview

Section A

(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.
$2.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
RishabKumar

Also available in package deal

Get to know the seller

Seller avatar
RishabKumar IIT Bombay
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
2 year
Number of followers
0
Documents
7
Last sold
-
Graduate physics study material

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions