-7
SVKM's NMIMS
School of Mathematical Sciences
Programme: B.Sc. Mathematics (Honours) Year: I Semester: I
Academic Year: 2019-20
Subject: Basics of Programming Languages Marks: 50
Date: 13 November 2019 Time: 11:00 am -02:00 pin
Duration: 3 hours
Number of Pages: 4
Final Examination
Instructions__I
• put,uLLLu sheets, one Ior rarb I an another for rat
d±
• Questions 1 to 20 is in Part I. Use of computer is not allowed for this Part I.
• Use of computer is allowed for part Il. T sheet of p II F,'iE b .`'1-D+T
a '--v
1. Which command is used to clear a command Window? (1 Mark)
i)clear ii)closeall iii)clc iv)clearall.
2. Executing the following code in the Command Window (1 Mark)
a; = [1 : 3.4; -6 : 3.5 : 0.5]; size(x) returns
i) error message ii) 2 2 iii) 2 3 iv) none of the above.
3. Executing the following code in the Command Window (1 Mark)
a = (1 : 3)'; (a(1, 2))'
returns
i)3 ii)1 iii)2 iv)noneoftheabove.
4. Which of the following is correct? (1 Mark)
i) fplot(sin, [0,1])
ii) fylot('sin', [0,1])
iii) fplot(@ sin, [0,1])
iv) None.
Ptl/"/4
LiEI
5. Which of the following is not a pre-defined variable in Matlab (1 Mark)
i)pi
ii) imf
iii) i
iv) gravity.
6. To print a newline in a fprintf statement, you must use the following escape character: (1 Mark)
i)V
ii) \"i
iii) \7tgt
iv) \7t. (1 Mark)
7. Executing the following code in the Command Window (1 Mark)
ff = [1 : 3 : 7; -6 : 3.5 : 1]; a;(1, 3) returns
i)7 ii)5 iii)1 iv)noneoftheabove.
8. When inputting a matrix, each new row is separated by a (1 Mark)
Fin
HPIE i
iii) -
iv) , .
9. Given the matrices A and E, which matrix operation is not allowed by Matlab? (1 Mark)
A-[13;2 5]
8 -[1; 8]
i) 4. * 8(1)
ii) A\B
iii) B\A
iv) A * 8 .
10. What value does the variable g contain after the Ma,tlab code executes below? (1 Mark)
a)-[13 5]
q _- a . * a
g -g + 2;
i)[31127]
ii) nothing - operation is not possible
iii)[13 5]
iv) [3 5 7] .
parge2/4
EE 11. Guess the output of the following code:
(1 Mark)
for counter in (2, 3, 4, 5):
print (counter)
iv) None of the above .
12. Guess the output of the following code
(1 Mark)
if 2 + 2 == 4 and not 2 + 2 == 5 and 2 * 2 == 2 + 2
print("yes")
else:
print("no")
i) yes
ii) no
iii) Syntax error
iv) none of the above.
13. Guess the output of the following code:
(1 Mark)
for ch in range "hihi" :
print(ch.upper())
i)HI HI
iii) Syntax error
iv) 5.
14. Which of the fouowing gives the output 2/2.0 after executing?
(1 Mark)
i) import math
print(math.sqrt(4))
ii) for ¢ in range(0, 2):.
print(i)
iii) 4/((4 + 4)/2)
iv) 2 * * * 1.
parge3/4
rEE
15. Guess the output of the following code: (1 Mark)
for count in range(0, 5):
if 2 ==count:
continue
print(count)
iv) None of the above.
16. Which Of the fonowing will run without errors? (1 Mark)
i) round(45.856,2)
ii) round(32.576,2,5)
iii) round()
iv) round(0.368,2,-1).
17. Which of the following is not a type Of python operator? (1 Mark)
i) Assignment
ii) Comparison
iii) Ttuth value
iv) Logical.
18. What data type is the object below? (1 Mark)
I, = [1, 2,' A', 69]
i) list
ii) array
iii) tuple
iv) dictionary.
19. In order to store values in terms of key and value we use.what core data type? (1 Mark)
i) list
ii) array
iii) tuple
iv) dictionary.
(1 Mark)
20. Suppose t = (1, 2, 4, 3) which of the following is incorrect?
i) print(t[3])
ii) t[3]-4
iii) print(max(t) )
iv) print(len(t)).
poff 4/a .....-
S-'s NMIMS
SCHOOL OF MATHEMATICAL SCIENCES
Programme: B.Sc. Mathematics (Honours) Year: I Semester: I
Academic Year: 2019-20
Subject: Basics of Programming Languages
Marks: 50
Date: 13 November 2019 Time: 11.00 am -2.00 pin
Durations: 3 (Hrs)
No. of Pages:
Final Ezamination ``.I
Part 11
21. (a) Write down the Python code of bisection method to solve the following equation (8 Marks)
82 -4 -0.
upto 7 decimal places, with tolerance .0001.
(b) Write down the Python code of NewtonJRaphson method to find a nonzero root of the
following equation, upto three decimal places (7 Marks)
ff2 + 4sin(a;) = 0.
Do 20 iteration with initial guess -4.
22. (a) Write down the Python code of Lagrange's method to get the value /(2) for the following
data (8 Marks)
X -2 .1 0 4
f(x) -2 4 1 8
(b) Use Matlab to write your code of Euler method to find the value of g(1) for the following
problem (7 Marks)
£-3+z-gr
gr(0) -0.
Take fa = o.1.
pargftyL