Quiznetik

Problem Solving and Python Programming | Set 5

1. What is called when a function is defined inside a class?

Correct : D. method

2. Lambda contains block of statements.

Correct : B. false

3. f(2, 30, 400)

Correct : A. 432

4. who('Arthur')

Correct : B. sir arthur

5. min(101*99, 102*98)

Correct : C. 9996

6. ) print(i)

Correct : C. 0

7. How are keyword arguments specified in the function heading?

Correct : C. two stars followed by a valid identifier

8. , 2, 3])

Correct : A. 3 1

9. print(foo())

Correct : C. error

10. How are variable length arguments specified in the function heading?

Correct : A. one star followed by a valid identifier

11. What is the value stored in sys.argv[0]?

Correct : C. the program’s name

12. How are default arguments specified in the function heading?

Correct : A. identifier followed by an equal to sign and the default value

13. Where are the arguments received from the command line stored?

Correct : A. sys.argv

14. san(12)

Correct : A. 13

15. , 5])?

Correct : A. [3, 4, 5, 20, 5, 25, 1, 3, 34, 5]

16. print(len(numbers))

Correct : B. 5

17. 2 TUPLES (TUPLE ASSIGNMENT, TUPLE AS RETURN VALUE)

Correct : B. (1, 2, 3)

18. >>>2 * t

Correct : A. (1, 2, 1, 2)

19. ,2,3

Correct : C. no, too many values to unpack

20. ] test[1] = 'D' del test[2] print(len(test))

Correct : B. 2

21. print(a)

Correct : B. false

22. To open a file c:\scores.txt for reading, we use

Correct : B. infile = open(“c:\\scores.txt”, “r”)

23. To read the remaining lines of the file from a file object infile, we use

Correct : D. infile.readlines()

24. What is the current syntax of remove() a file?

Correct : A. remove(file_name)

25. Which of the following mode will refer to binary data?

Correct : D. b

26. What is the difference between r+ and w+ modes?

Correct : B. in r+ the pointer is initially placed at the beginning of the file and the pointer is at the end for w+

27. How do you get the name of a file from a file object (fp)?

Correct : A. fp.name

28. Which function overloads the + operator?

Correct : A. add    ()

29. k = foo() print(k)

Correct : B. 2

30. g=f(8) print(next(g))

Correct : B. 9