Python Program MCQ
Test your knowledge with important Python Program MCQ and their applications. These MCQs are beneficial for competitive exams too. Explore 30+ more Python Program MCQs on Bissoy. Bissoy App
-
Which of the following will throw an error if used after the following Python code?<br><pre><code class="python">tday=datetime.date.today()bday=datetime.date(2017,9,18)t_day=bday-tday</code></pre>
-
State whether true or false.<br><pre><code class="python">s = time.time()t= time.time()s == t</code></pre>
-
The sleep function (under the time module) is used to . . . . . . . .
-
The copy module uses the . . . . . . . . protocol for shallow and deep copy.
-
Point out the error (if any) in the code shown below if the system date is 18th June, 2017?<br><pre><code class="python">tday=datetime.date.today()bday=datetime.date(2017,9,18)till_bday=bday-tdayprint(till_bday)</code></pre>
-
Fill in the blank such that the following Python code results in the formation of an inverted, equilateral triangle.<br><pre><code class="python">import turtlet=turtle.Pen()for i in range(0,3):t.forward(150)t.right(_____)</code></pre>
-
Which of the following will never be displayed on executing print(random.choice({0: 1, 2: 3}))?
-
How can you create your own module in Python?
-
How can you uninstall a Python module using pip?
-
What is x if x = math.isfinite(float('0.0'))?
-
What is the purpose of the from __future__ import ... statement in Python?
-
Which of the following aren't defined in the math module?
-
Which of the following isn't true about main modules?
-
The output of the following Python code is similar to the alphabet . . . . . . . .<br><pre><code class="python">import turtlet=turtle.Pen()t1=turtle.Pen()t2=turtle.Pen()t.forward(100)t1.forward(100)t2.forward(100)t1.left(90)t1.forward(75)t2.right(90)t2.forward(75)</code></pre>
-
The output of both of the print statements is the same.<br><pre><code class="python">import datetimedt_1 = datetime.datetime.today()dt_2 = datetime.datetime.now()print(dt_1)print(dt_2)</code></pre>
-
The output of the following two Python codes is exactly the same.<br><pre><code class="python">object'a'CODE 1>>> pickle.dumps('a', 3)CODE 2>>> pickle.dumps(object, 3)</code></pre>
-
How can you create a Python package?
-
What does the dir() function in Python do?
-
The output of the following Python code will result in a shape similar to the alphabet . . . . . . . .<br><pre><code class="python">import turtlet=turtle.Turtle()t1=turtle.Turtle()t.left(45)t1.left(135)t.forward(100)t1.forward(100)</code></pre>
-
What is the output of the following code:<br><code>def my_function(a, b):<br> return a * b<br>result = my_function(4, 0)<br>print(result)</code>
-
What is the output of the following code:<br><code>def greet(name="User"):<br> print(f"Hello, {name}!")<br>greet()</code>
-
Which of the following numbers will not be a part of the output list of the following Python code?<br><pre><code class="python">def sf(a): return a%3!=0 and a%5!=0m=filter(sf, range(1, 31))print(list(m))</code></pre>
-
In . . . . . . . . copy, the base address of the objects are copied. In . . . . . . . . copy, the base address of the objects are not copied.
-
What is the output of the following code:<br><code>def multiply(a, b=2):<br> return a * b<br>result = multiply(4)<br>print(result)</code>
-
What is the output of the following code:<br><code>def power(x, n=2):<br> return x ** n<br>result = power(3)<br>print(result)</code>
-
How can you define a function that accepts an arbitrary number of keyword arguments?
-
What does the nonlocal keyword do when used in a function?
-
The single line equivalent of the following Python code?<br><pre><code class="python">l=[1, 2, 3, 4, 5
-
What is the purpose of using the * symbol in function argument packing?
-
How are default arguments specified in the function heading?