Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

COMPUTATIONAL PHYSICS----→>>Python basics MCQ

1. What is a correct syntax to output "Hello World" in Python?


(a) p("Hello World")
(b) echo"Hello World"
(c) echo("Hello World")
(d) print("Hello World")
2. How do you insert COMMENTS in Python code?
(a) */This is a comment*/
(b) //This is a comment
(c) #This is a comment
(d) C This is a comment
3. Which one is NOT a legal variable name?
(a) my-var
(b) _myvar
(c) myvar
(d) my_var
4.A while loop in Python is used for what type of iteration?
(a) definite
(b) indefinite
(c) discriminant
(d) indiscriminant

5.What is the output of the following code snippet:

(a) The snippet doesn’t generate any output.


(b) (‘baz’,3)
(‘bar’,2)
(‘foo’,1)
Done
(c) foo
bar
baz
(d) Done

6.What is the output of the following code snippet:

(a) The snippet doesn’t generate any output.


(b) (‘baz’,3)
(‘bar’,2)
(‘foo’,1)
Done
(c) foo
bar
baz
(d) Done

7. Which of the following statements about Python are true? (Multiple Choice)
A. It was created by Guido van Rossum, the Dutchman, in 1989, and it was first
released in 1991.
B. Python is a kind of free software and its open-source code complies with the
GPL (GNU General Public License) Protocol.
C. The Python syntax is simple and clear, characterized by using blank
characters for indentation.
D. Python is often nicknamed "glue language" because it can easily glue
together various modules developed in other languages.

8. (True or False) Multiple Python statements can be written in one line with
commas (,) between the statements. ()
A. TRUE
B. FALSE

9. (Single-Answer Question) Which of the following is not a Python operator? ()


A. Arithmetic operator
B. Inference operator
C. Logical operator
D. Comparison operator

10. (Single-Answer Question) Which of the following statements about Python


regular expression is not true? ()
A. re regular expression module was added in Python 1.5.
B. re module grants all regular expression functions to Python.
C. re regular expression is a powerful tool to process strings.
D. re regular expression can only process character string data, not numerical
data.

11. Functions are well-organized, non-reusable code segments used to


implement a single, or associated function.
A. True
B. False
12. As the following, what are the Python language design philosophy?
(Multiple Choice)
A. Beautiful
B. Expensive
C. Explicit
D. Simple
13. Python tuples are identified by "()" and internal elements are separated by
":".
A. True
B. False

14. What are the numeric types of Python? (Multiple Choice)


A. int (integer type)
B. long (long integer type)
C. float (floating point type)
D. complex (complex number type)

You might also like