Home / Engineering / Problem Solving and Python Programming MCQs / Page 35

Problem Solving and Python Programming MCQs | Page - 35

Dear candidates you will find MCQ questions of Problem Solving and Python Programming here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.

`Q. 341) ] test[1] = 'D' del test[2] print(len(test))`

(A) 0
(B) 2
(C) error as the key-value pair of 1:’a’ is already deleted
(D) 1

(A) true
(B) false
(C) ---
(D) ---

`Q. 343) To open a file c:\scores.txt for reading, we use `

(A) infile = open(“c:\\scores.txt”, “r”)
(B) infile = open(“c:\\scores.txt”, “r”)
(C) infile = open(file = “c:\\scores.txt”, “r”)
(D) infile = open(file = “c:\\scores.txt”, “r”)

`Q. 345) What is the current syntax of remove() a file?`

(A) remove(file_name)
(B) remove(new_file_name, current_file_name,)
(C) remove(() , file_name))
(D) none of the mentioned

(A) r
(B) w
(C) +
(D) b

`Q. 347) Write a list comprehension for producing a list of numbers between 1 and 1000 that are divisible by 3.`

(A) [x in range(1, 1000) if x%3==0]
(B) [x for x in range(1000) if x%3==0]
(C) [x%3 for x in range(1, 1000)]
(D) [x%3=0 for x in range(1, 1000)]

`Q. 348) Write a list comprehension to produce the list: [1, 2, 4, 8, 16……212].`

(A) [(2**x) for x in range(0, 13)]
(B) [(x**2) for x in range(1, 13)]
(C) [(2**x) for x in range(1, 13)]
(D) [(x**2) for x in range(0, 13)]

`Q. 349) , x is even} (including zero)`

(A) [x for x in range(1, 20) if (x%2==0)]
(B) [x for x in range(0, 20) if (x//2==0)]
(C) [x for x in range(1, 20) if (x//2==0)]
(D) [x for x in range(0, 20) if (x%2==0)]

`Q. 350) , i)]`

(A) a list of prime numbers up to 50
(B) a list of numbers divisible by 2, up to 50
(C) a list of non prime numbers, up to 50
(D) error

Download our easy to use, user friendly Android App from Play Store. And learn MCQs with one click.