100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Python Programming Mock Papers $2.99   Add to cart

Other

Python Programming Mock Papers

 5 views  0 purchase
  • Course
  • Institution

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...

[Show more]

Preview 1 out of 6  pages

  • May 7, 2023
  • 6
  • 2022/2023
  • Other
  • Unknown
avatar-seller
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.

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

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.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes 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 these notes for $2.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79751 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$2.99
  • (0)
  Add to cart