You are on page 1of 2

Surprise Test I

Computational Physics and Programming (PHY-5405)


Dated: 2nd July 2021
Time : 30 minutes
Marks: 50
State True or False:

1. Declaration of variables can appear anywhere in a program.


2. Python treats the variables total and Total to be same.
3. Initialization is the process of assigning a value to a variable at the time
of declaration.
4. Variables can’t be initialized at the time of declaration.
5. Arithmetic operators do not have the same level of precedence.
6. The modulo operator (%) can be used only with integers.
7. When evaluation of mixed expressions, an implicit cast is generated
automatically.
8. Parentheses can be used to change the order of evaluation expressions.
9. The input () function may contain one or more variables
10. The input() function can’t be used for reading a single character from
the keyboard.
11. If the field width of a format specifier is larger than the actual width of the
value, the value is printed right justified in the field.
12. The input() function can read more than one values at one time.
13. The input() function is used for reading integer values only.
14. When if statements are nested, the last else get associated with the
nearest if without an else.
15. One if statement can have more than one else clause.
16. Program stops its execution when a break statement is encountered.
17. Any expression can be used for the if expression.
18. Each expression in the elif clause must test the same variable.
19. The expression !(a != b) is equivalent to the expression (a == b).
20. In a loop, if the body is executed n times, then the test condition is
executed n+1 times.
21. In a for loop expression, the starting value of the control variable must be
less than its ending value.
22. while loops can be used to replace for loops without any change in the
body of the loop.
23. The len() function can’t be used in while loops.
24. The break statement is used to skip a part of the statements in a loop.
25. The else statement can’t be used with for or while loop.
26. In a nested loop the break statement will come out only from the inner
loop.
27. A function header begins with the def keyword followed by function’s
name and parameters, and ends with a semicolon.
28. Parameters are optional; that is, a function does not have to contain any
parameters.
29. A return statement can also be used in a void(None) function for
terminating the function and returning to the function’s caller.
30. The arguments that are passed to a function may or may not have the
same number, type, and order as the parameters in the function header.
31. The return statement can return multiple values.
32. Every element in a list must have the same type.
33. A list’s size is fixed after it is created.
34. A list can have duplicate elements.
35. The elements in a list can be accessed via an index operator.
36. The shuffle function in the random module to is to shuffle the elements
in a list.
37. The index of the first element in a list starts with 1.
38. The concatenation operator + is used to concatenate two lists of same
size.
39. The expression 10 + 6//5 * 5//6 evaluates to 10.
40. The statement a = 1/3 + 1/3 + 1/3 assigns 1 to a.

Find errors, if any, in the following declaration statements and explain it.
41. 5 = radius
42. x + y = z
43. class = “Python”
44. b =+ 20
45. number1 = 23.46
46. 2number = 34.56
47. Row Total = 123
48. List1=[‘6’, ‘8’, ‘9’]
49. List1=[6, 8, 9]
50. if (a > 0 or b > 0 );
print ” Both are positive.”
Important Note:

1. Please submit your answer (scan copy) to the mail address:


mshubhakanta@yahoo.com before 02:30 PM. Submission after this time will not
evaluated and marked as absent.

2. Write your Name and Exam Roll No. clearly at the top of the answer script.

You might also like