CU SEC-2 Python Programming and LaTeX, 2025

University of Calcutta question paper, B.Sc. Honours Semester II, 2025. Python Programming and LaTeX. Typed in LaTeX, searchable, with a printable PDF.

Open this paper in MathQP

  1. What is a function in Python? Mention any one type of function with an example.
  2. What is len() function and explain how it is used on strings with an example.
  3. Write the output of the following code: l texttt i, j, k = 4, -1, 0 texttt x = i and j and k texttt y = i or j and k texttt z = i and j or k texttt print (x, y, z)
  4. Write the output of the following Python code: l texttt L = ['This', 'is', 'our', 'first', 'exam'] texttt print (L[-3]) texttt print (L[-4 : 4]) texttt L[3] = 'second' texttt print(L)
  5. Compare a list and a tuple in Python.
  6. Write code using SymPy to compute the following expression: x 2e 3y +y log x , for x=2 and y=3 .
  7. What will be the output of the following Python code? (i) l texttt x = 5 + 4 / 2 * 3 - 16 (ii) l texttt y = 8 + 2 ** 3 ** 2 // 4
  8. What are the outputs of following Python codes? (i) l texttt i = 15 texttt while 1 : hspace 2.0em texttt print (i, end = ';') hspace 2.0em texttt i -= 3 hspace 2.0em texttt if i < 0: hspace 4.0em texttt break (ii) l texttt print (5/3*4//2**2) (iii) l texttt n = 22/7; print (f "The value of n is : n:5.4f ")
  9. Write a program in Python to find the binary equivalent to a given positive integer with or without recursion.
  10. (i) Write Python codes to solve the following equations using SymPy: x+2y+z=1 and x+3y+2z=3 . (ii) Write a Python program to print the multiplication table of 9.
  11. Write code to plot the following two functions in one graph using SymPy: (i) f(x)=x 2-1 in (-3,3) in color blue. (ii) g(x)=x 2+2 in (-3,3) in color black.
  12. Write the output of the following Python codes: (i) l texttt s1 = "Good Morning" texttt s2 = s1.lower() texttt print (s2) (ii) l texttt l = [1, 3, 5, 7, 9] texttt print (l [2]) texttt print (l [-2]) (iii) l texttt m = [2, 6, 2, 4, 2, 6] texttt C1 = m.count(2) texttt C2 = m.count(8) texttt print (C1) texttt print (C2)
  13. Write a Python program to test whether a given positive integer ( >1 ) is prime or not.
  14. Write a Python program to find the roots of a quadratic equation ax 2+bx+c=0 . ( a,b,c : real and a ne 0 )
  15. (i) Write code using SymPy to simplify dfrac x 3-1 x-1 . (ii) Write code using SymPy to find the roots of the equation x 2-5x+6=0 .
  16. Write Python codes to input two 3 times 3 matrices A and B and find their sum and display it.
  17. Write a Python function to find factorial of a number. Use it to compute 1! ,2!+2! ,3!+3! ,4!+ dots +10! ,11! .
  18. Write command in LaTeX for writing the following: f: mathbb R to mathbb R s.t. f(x)=2x+9 , x in mathbb R .
  19. Write code in LaTeX to insert an image as input in the document.
  20. Write LaTeX command for the following output: 1 2 3 4 5 6 7 8 9 =0.
  21. What is the output of the following LaTeX code? l texttt textdollar textdollar f(x) = textbackslash sum n = 0 textasciicircum textbackslash infty textbackslash frac f textasciicircum (n) (a) n! (x - a) textasciicircum n textdollar textdollar
  22. Write LaTeX commands to create the following equation with equation number: x alpha +e 2x 2 - beta x=0 (1).
  23. Write the command in LaTeX to generate the expression nabla 2f(x,y)= dfrac partial 2f partial x 2 + dfrac partial 2f partial y 2 .
  24. Explain the difference between the outputs of the following two LaTeX source codes: (i) Suppose that l texttt textdollar x = 25 textdollar is a solution. (ii) Suppose that l texttt textdollar textdollar x = 25 textdollar textdollar is a solution.
  25. What is the wrong with the following input in LaTeX command? What is the right way to do it? l texttt textbackslash Documentclass article texttt textbackslash usepackage amsmath texttt textbackslash begin document texttt We have following options texttt textbackslash begin itemize texttt textbackslash item textdollar textdollar x textbackslash ge y textdollar texttt textbackslash item textdollar x textbackslash le y textdollar texttt textbackslash item x = y texttt textbackslash end document
  26. Write a block of codes in LaTeX to typeset the following: A system of linear equation in three variables x 1,x 2 and x 3 can be represented as: a 11 a 12 a 13 a 21 a 22 a 23 a 31 a 32 a 33 x 1 x 2 x 3 = 2 3 4 .
  27. Write a block of LaTeX source code to create the following table: |l|c|c| hline Planet Maximum Minimum hline Mercury 69.4 46.8 Venus 109.0 107.6 Earth 152.6 147.4 hline
  28. Write a block of LaTeX code to display the mathematical expression: sec theta sec 2 theta sec dfrac theta 2 1 lambda lambda 2 sqrt tan theta cos phi sin psi .
  29. Write a block of LaTeX code to print the following system of equations in its present form: x tan ( alpha )+y cos ( gamma )+z delta = log (3 psi ) , ax+by- alpha beta =1 , C P-C V= dfrac VT beta 2 K T .