Python One Linear MCQ Quiz for O Level

0%
Question 1

What is the main goal of white box testing?
White Box परीक्षण का मुख्य लक्ष्य क्या है?

A) To test the software without knowledge of internal structure.
B) To ensure that the internal operation of a program is functioning as expected.
C) To Test the system's performance under heavy loads.
D) To simulate the interface and user experience.
Question 2

What will be the output of the following python expression? 24//6%3, 24//4//2

A) (1,3)
B) (1,1)
C) (1,9)
D) (1,5)
Question 3

Program code making use of a given module is called a ________of the module
किसी दिए गए मॉड्यूल का उपयोग करने वाले प्रोग्राम कोड को मॉड्यूल का ________ कहा जाता है

A) Client
B) Docstring
C) Interface
D) Modularity
Question 4

What is called when a function is defined inside a class?
जब किसी क्लास के अंदर कोई फ़ंक्शन परिभाषित किया जाता है तो उसे क्या कहा जाता है?

A) Module
B) Class
C) Another function
D) Method
Question 5

In while loop, how can you prevent it from becoming an infinite loop?
while लूप को अनंत लूप बनने से आप कैसे रोक सकते हैं?

A) Use the break statement at the end of the body loop
B) Including an else statement with a termination condition
C) Ensure that the loop condition becomes False at some point
D) Add a continue statement at the beginning of the body loop
Question 6

What is the purpose of numpy arange() function?
numpy arange() फ़ंक्शन का उद्देश्य क्या है?

A) To create a sequence of numbers with a specified step size
B) To create a random array of specified shape and values
C) To create an array of ones with a specified shape
D) To create an array of zeros with a specified shape
Question 7

What is the correct way to open a file in binary read mode in python?
पायथन में बाइनरी रीड मोड में फ़ाइल खोलने का सही तरीका क्या है?

A) open('file.txt', 'b')
B) open('file.txt', 'rb')
C) open('file.txt', 'rbin')
D) open('file.txt', 'read-binary')
Question 8

What will be the data type of the var in the below code snippet?

    var = 10
    print(type(var))
    var = "hello"
    print(type(var))
A) str and int
B) int and int
C) str and str
D) int and str
Question 9

What is the result of the bitwise OR operation between 10 and 6?
10 और 6 के बीच बिटवाइज़ OR ऑपरेशन का परिणाम क्या है?

A) 4
B) 14
C) 16
D) 24
Question 10

What is the output of the following expression? np.linspace(0,10,5)
निम्नलिखित अभिव्यक्ति का आउटपुट क्या है? np.linspace(0,10,5)

A) [0, 2, 4, 6, 8, 10]
B) [0, 2, 4, 6, 8]
C) [0, 2.5, 5, 7.5, 10]
D) [0.0, 2.5, 5.0, 7.5, 10.0]
Question 11

_________ is not a valid namespace
यह वैध नामस्थान नहीं है

A) Global namespace
B) Public namespace
C) Built-in namespace
D) Local namespace
Question 12

What will be following code output?
निम्नलिखित कोड आउटपुट क्या होगा?

    def outer():
        x=5
        def inner():
            nonlocal x
            x=10
        inner()
        print(x)
    outer()
A) 5
B) 10
C) None
D) Error
Question 13

Which of the following option is the correct statement to read and display the first 10 character of a text file "doc.txt"
निम्नलिखित में से कौन सा विकल्प टेक्स्ट फ़ाइल "doc.txt" के पहले 10 अक्षर को पढ़ने और प्रदर्शित करने के लिए सही कथन है

A) F=open('doc.txt'); print(F.load(10))
B) F=open('doc.txt'); print(F.dump(10))
C) F=open('doc.txt'); print(F.read(10))
D) F=open('doc.txt'); print(F.write(10))
Question 14

Let us import the numpy in your program as follows:
from numpy import random as np.
Which of the following can be the probable output for the instruction,
print(np.randint(100))
आइए हम आपके प्रोग्राम में numpy को इस प्रकार आयात करें: from numpy import random as np. निम्न में से कौन सा निर्देश, print(np.randint(100)) के लिए संभावित आउटपुट हो सकता है

A) 56
B) 156
C) 256
D) 356
Question 15

What will be the output of following instructions: print(np.array([[1,2,3],[4,5,6]]).shape)

A) (1,2)
B) (1,2,3)
C) (2,3)
D) (4,5)
Question 16

Given the following code, what will be the output?
निम्नलिखित कोड दिया गया है, आउटपुट क्या होगा?

    import numpy as np
    arr=np.array([1,2,3,4,5,6,7,8,9])
    print(arr[::3])
A) [1,4,7]
B) [1,2,3]
C) [1,2,3,4,5]
D) [1,3,5,7,9]
Question 17

What is the significance of "continue" statement in a for loop?
फॉर लूप में "continue" कथन का क्या महत्व है?

A) To exit the loop
B) To skip the remaining code and move to the next iteration
C) To restart the loop from the beginning
D) To print the current iteration and continue
Question 18

What is the output of the following code? print(bool(0), bool(2.15), bool(-5), bool(2.0+1j))

A) True True False True
B) True False False True
C) False True False True
D) False True True True
Question 19

What will be the output of the following Python Code?

    a = {1:"A",2:"B",3:"C"}
    b = {4:"D",5:"E"}
    a.update(b)
    print(a)
A) {1:'B', 2:'B', 3:'C'}
B) Method update() doesn't exist for dictionaries
C) {1:'B', 2:'B', 3:'C', 4:'D', 5:'E'}
D) {1:'A', 2:'B', 3:'C', 4:'D', 5:'E'}
Question 20

Kite box in a flow chart is used for _________
फ्लो चार्ट में काइट बॉक्स का उपयोग किसके लिए किया जाता है?

A) Connector
B) Decision
C) Statement
D) All of the above
Question 21

Execution of the following python statement will result in open("filename.txt", "w").write("Great Day\n")
निम्नलिखित पायथन कथन के निष्पादन का परिणाम open("filename.txt", "w").write("Great Day\n") होगा

A) Error
B) File not closed
C) Writing of file is not performed
D) None of the above
Question 22

What will the following code print? x = [0,1,2,3,4,5] print(x[1:5:2])

A) [1,2,3,4]
B) [1,3]
C) [2,4]
D) Error
Question 23

What is the advantage of Flow chart?
फ्लो चार्ट का क्या लाभ है?

A) Systematic testing
B) Asystematic testing
C) Symmetric testing
D) Improper Communication
Question 24

What will be the output of the following Python code?

        L1 = [2, 4, 6]
        L2 = [-2, -4, -6]
        for i in zip(L1, L2):
            print(i)
A) 2 -2
4, -4
6, -6
B) [(2,-2), (4,-4), (6,-6)]
C) (2, -2)
(4, -4)
(6, -6)
D) [-4, -16, -36]
Question 25

What is the result of the following code?

        lst = [1, 2, 3, 4, 5]
        lst[1:4] = [6, 7, 8]
        print(lst)
A) [1,6,7,8,5]
B) [1,6,7,8]
C) [6,7,8,4,5]
D) IndexError
Question 26

What of the following extension is not a binary file?
निम्नलिखित में से कौन सा एक्सटेंशन बाइनरी फ़ाइल नहीं है

A) .py
B) .exe
C) .mp3
D) .jpeg
Question 27

What will be the output of the python code? re.split("mum", "mumbai*", 1)
पायथन कोड का आउटपुट क्या होगा? re.split("mum", "mumbai*", 1)

A) Error
B) ["", "bai*"]
C) ["", "bai"]
D) ['bai*']
Question 28

Which of the following method converts all capital letters of a string into small letters?
निम्नलिखित में से कौन सी विधि किसी स्ट्रिंग के सभी बड़े अक्षरों को छोटे अक्षरों में परिवर्तित करती है?

A) small()
B) lower()
C) lowercase()
D) smallcase()
Question 29

In file handling, what does this terms means "r, a"?
फ़ाइल हैंडलिंग में, इस शब्द का क्या अर्थ है "आर, ए"

A) Read, append
B) Append, read
C) Write, append
D) None of the mentioned
Question 30

How do you get the name of a file from a file object(fp)?
आप फ़ाइल ऑब्जेक्ट (fp) से फ़ाइल का नाम कैसे प्राप्त करते हैं?

A) fp.name
B) fp.file(name)
C) self.__name__(fp)
D) fp.__name__()
Question 31

Which of the following is the correct way to create a dictionary in Python?
पायथन में शब्दकोश बनाने का सही तरीका निम्नलिखित में से कौन सा है?

A) {1:"one", 2:"two", 3:"three"}
B) (1:'one', 2:'two', 3:'three')
C) [1:'one', 2:'two', 3:'three']
D) {1,'one', 2,'two', 3,'three'}
Question 32

What does the following symbol shows? O
निम्नलिखित प्रतीक क्या दर्शाता है?

A) Decision
B) Input
C) Processing
D) Terminal process
Question 33

What will be the output of the following Python code?

        def foo():
            try:
                return 1
            finally:
                return 2
        k = foo()
        print(k)
A) Error, three is more than one return statement in a single try-finally block
B) 3
C) 2
D) 1
Question 34

Which module in python is used for regular expressions?
पायथन में कौन सा मॉड्यूल नियमित अभिव्यक्तियों के लिए उपयोग किया जाता है?

A) regex
B) re
C) Rex
D) regx
Question 35

To read the remaining lines of the file from a file object infile, which of the following can be used?
फ़ाइल ऑब्जेक्ट इनफ़ाइल से फ़ाइल की शेष पंक्तियों को पढ़ने के लिए, निम्नलिखित में से किसका उपयोग किया जा सकता है?

A) infile.read(2)
B) infile.read()
C) infile.readline()
D) infile.readlines()
Question 36

What will be the output of the following python code snippet?

        test = {1:'A', 2:'B', 3:'C'}
        del test[1]
        test[1] = 'D'
        del test[2]
        print(len(test))
A) 2
B) 0
C) 1
D) Error as the key-value pair of 1:'A' is already deleted
Question 37

Docstring refers to the ___________
डॉकस्ट्रिंग का तात्पर्य है

A) String value of a variable of str datatype
B) String literal that occurs as the first statement in a module, function, class, or method definition
C) Documents attached with software
D) None of the above
Question 38

What will be the output of the following python code?

        def f1(a,b=[]):
            b.append(a)
            return b
        print(f1(2,[3,4]))
A) [3,2,4]
B) [3,4,2]
C) [2,3,4]
D) Error
Question 39

What will be the following code output?

        import numpy as np
        arr = np.array([10, 20, 30, 40, 50])
        print(arr[arr > 30])
A) [30, 40, 50]
B) [10, 20]
C) [40, 50]
D) Error: Invalid comparison
Question 40

If A = 0 then GCD(A,B) is __________

A) A
B) B
C) A*A
D) 1
Question 41

What will be the output of the following Python code?

        string="my name is x"
        for i in string.split():
            print(i, end=",")
A) m,y, ,n,a,m,e, ,i,s, ,x,
B) my,name,is,x,
C) m,y, ,n,a,m,e, ,i,s, ,x
D) error
Question 42

What is the output of the following code?

        import numpy as np
        a=np.array([1,2,3])
        b=np.array([4,5,6])
        c=np.stack((a,b))
        print(c)
A) [[1,2,3],[4,5,6]]
B) [[1,4],[2,5],[3,6]]
C) [1,2,3,4,5,6]
D) Error
Question 43

What will be the following output of the following statement: print(3.2**2**3+99/11)

A) 244
B) 244.0
C) -244.0
D) Error
Question 44

Consider the following syntax for file open function Filehandler=open("filename","open mode","buffering") which of the following statement is False?
फ़ाइल ओपन फ़ंक्शन के लिए निम्नलिखित सिंटैक्स पर विचार करें Filehandler=open("filename","open mode","buffering") निम्नलिखित में से कौन सा कथन गलत है?

A) No buffering will be used if 0 is passed as buffering integer
B) 0 as buffering integer is allowed only in text mode
C) 0 as buffering integer is allowed only in binary mode
D) Positive integer as buffering integer implies full buffering
Question 45

What is the result of the following code?

        st=[1,2,3,4,5]
        st[1:4]=[6,7,8]
        print(lst)
A) [1,6,7,8,5]
B) [1,6,7,8]
C) [6,7,8,4,5]
D) NameError
Question 46

What will be the output of the following Python code?

        #mod1
        def change(a):
            b=[x*2 for x in a]
            print(b)
        #mod2
        def change(a):
            b=[x*x for x in a]
            print(b)
        from mod1 import change 
        from mod2 import change
        #main
        s=[1,2,3]
        change(s)
A) [2,4,6]
B) [1,4,9]
C) [2,4,6][1,4,9]
D) There is a name clash
Question 47

What will be the output of the following Python function? min(max(False,-3,-4),2,7)
निम्नलिखित पायथन फ़ंक्शन का आउटपुट क्या होगा? min(max(False,-3,-4),2,7)

A) -4
B) -3
C) 2
D) False
Question 48

What will be the following code output?

        import numpy as np
        arr=np.array([10,20,30,40,50])
        print(arr[arr>30])
A) [30,40,50]
B) [10,20]
C) [40,50]
D) Error: Invalid comparison
Question 49

Which of the following is the output of the instruction, print(math.log(64,2))

A) 6.0
B) 7.0
C) 2.0
D) 64.0
Question 50

Which of the following functions can delete an element from a list, if it's value is given?
निम्नलिखित में से कौन सा फ़ंक्शन किसी सूची से किसी तत्व को हटा सकता है, यदि उसका मान दिया गया हो?

A) pop()
B) remove()
C) del()
D) all of these
Question 51

Observe the following code and identify what will be the outcome?

        import numpy as np
        a=np.array([10,20,30,40])
        b=np.array([18,15,14])
        c=np.array([25,24,26,28,23])
        x,y,z=np.ix_(a,b,c)
        print(x)
A) [[[10]] [[20]] [[30]] [[40]]]
B) [[[1]] [[2]] [[3]] [[4]] [[5]]]
C) Both a and b
D) Error
Question 52

What does the following code print to the console? >>if 88>100:print("cardio")

A) 88
B) cardio
C) 100
D) Nothing is printed
Question 53

Istrip() method is used for
Istrip() विधि का उपयोग किसके लिए किया जाता है?

A) Delete all the leading characters
B) Delete all the trailing characters
C) Delete all the leading and trailing characters
D) Delete uppercase characters
Question 54

What will be the output of following Python expression if x=56.236? print("%.2f"%x)

A) 56.236
B) 56.23
C) 56
D) 56.24
Question 55

Which of the following is NOT a sequence data type in Python?
निम्नलिखित में से कौन पायथन में अनुक्रम डेटा प्रकार नहीं है?

A) String
B) List
C) Dictionary
D) Tuple
Question 56

Recursive function is ___________________.
पुनरावर्ती फलन ___________________ है।

A) A function that calls itself
B) A function that calls other functions
C) Both
D) None of the above
Question 57

Documentation in software development is important because it__________________.
सॉफ्टवेयर विकास में दस्तावेज़ीकरण महत्वपूर्ण है क्योंकि यह__________________.

A) Helps in maintaining the program in the long term
B) Is required by law for all software projects
C) Ensures the program's compatibility with different platforms
D) Replaces the need for testing and debugging
Question 58

What is the result of the following Python expression 5//3**2?

A) 0
B) 1
C) 4
D) Error message
Question 59

What is the output of the following code?

        import numpy as np
        a=np.array([[1,2],[3,4]])
        print(a.ndim)
A) 0
B) 1
C) 2
D) 3
Question 60

Which function is used to return the current file position in bytes?
वर्तमान फ़ाइल स्थिति को बाइट्स में लौटाने के लिए किस फ़ंक्शन का उपयोग किया जाता है?

A) tell()
B) seek()
C) read()
D) write()
Question 61

What is the value returned by math.floor(3.4)?
math.floor(3.4) द्वारा लौटाया गया मान क्या है?

A) 3
B) 4
C) 3.0
D) 4.0
Question 62

Which operator is used for slicing an ndarray?
Ndarray को स्लाइस करने के लिए किस ऑपरेटर का उपयोग किया जाता है?

A) ,
B) :
C) ;
D) /
Question 63

Which of the following statement display "ARM" two times?

A) >>>"ARM" ++2
B) >>>"ARM" +2
C) >>>"ARM" *2
D) >>>"ARM" **2
Question 64

Algorithm cannot be represented by ________________.
एल्गोरिथ्म को ________________ द्वारा प्रदर्शित नहीं किया जा सकता।

A) pseudo codes
B) syntax
C) flowcharts
D) programs
Question 65

What is NumPy?

A) A programming language
B) A library for numerical computing in Python
C) A data visualization tool
D) A file format for storing data
Question 66

Which of the following is true about function argument in Python?
पायथन में फ़ंक्शन तर्क के बारे में निम्नलिखित में से कौन सा सत्य है?

A) All arguments must have default values
B) Only keyword arguments can be used
C) Only one argument is allowed in a function
D) Arguments are optional can be omitted
Question 67

What is the purpose of the for loop in Python?
पायथन में फॉर लूप का उद्देश्य क्या है?

A) To define a function
B) To perform conditional execution
C) To iterate over a sequence of items
D) To execute a block of code when a condition is true
Question 68

Which of the following is true about the import statement in Python?
पायथन में import कथन के बारे में निम्नलिखित में से कौन सा कथन सत्य है?

A) It can only import one module at a time
B) It can import multiple modules at a time
C) It can import modules from any directory
D) It can import modules from any programming language
Question 69

How do you define a function in Python?
आप पायथन में फ़ंक्शन कैसे परिभाषित करते हैं?

A) def function_name():
B) function function_name():
C) define function_name():
D) def(): function_name
Question 70

What does the seek() function do in Python?
पायथन में seek() फ़ंक्शन क्या करता है?

A) Reads a specified number of characters from a file
B) Moves the file pointer to a specific position
C) Writes a line of text to a file
D) Closes a file
Question 71

____________ creates an inferior process that runs your program.
____________ एक निम्नस्तरीय प्रक्रिया बनाता है जो आपके प्रोग्राम को चलाता है।

A) Run
B) Exit
C) Execute
D) E
Question 72

What will be the output of the following Python code snippet?

        x='abcd'
        for i in range(len(x)):  
            i.upper()
        print(x)
A) a b c d
B) 0 1 2 3
C) error
D) none of the mentioned
Question 73

_________ refers to the ability to make decisions based on criteria conditions.
_________ मानदंड स्थितियों के आधार पर निर्णय लेने की क्षमता को संदर्भित करता है।

A) Sequence
B) Selection
C) Iteration
D) None of these
Question 74

Which of the following exceptions is raised if the file already exists when opening it in 'x' mode?
यदि फ़ाइल को 'x' मोड में खोलने पर वह पहले से मौजूद है, तो निम्न में से कौन सा अपवाद उत्पन्न होता है?

A) FileError
B) IOError
C) FileExistsError
D) None of these
Question 75

What is the purpose of the seek() method in Python file handling?
पायथन फ़ाइल हैंडलिंग में seek() विधि का उद्देश्य क्या है?

A) To move the file cursor to a specific position
B) To read the entire contents of a file
C) To write data to a file
D) To close a file
Question 76

Which of the following is the truncation division operator in Python?
निम्नलिखित में से कौन पायथन में ट्रंकेशन डिवीजन ऑपरेटर है?

A) |
B) //
C) /
D) %
Question 77

Which method is used to format the determine object according to the specified format string in Python?
पायथन में निर्दिष्ट प्रारूप स्ट्रिंग के अनुसार निर्धारित ऑब्जेक्ट को प्रारूपित करने के लिए किस विधि का उपयोग किया जाता है?

A) format()
B) strftime()
C) to_string()
D) convert
Question 78

What is the primary purpose of a decision structure in an algorithm or flowchart?
किसी एल्गोरिथम या फ्लोचार्ट में निर्णय संरचना का प्राथमिक उद्देश्य क्या है?

A) To perform mathematical calculations
B) To represent a process or operation
C) To control the flow of execution based on a condition
D) To store and retrieve data
Question 79

What is the value of i after the for loop?, for i in range(4):break
for loop के बाद i का मान क्या है?, for i in range(4):break

A) 1
B) 2
C) 3
D) 0
Question 80

Observe the following code and identify what will be the outcome?
निम्नलिखित कोड को देखिए और पहचानिए कि परिणाम क्या होगा?

        import numpy as np
        a=np.array([1,2,3,4,5,6]) 
        print(a)
A) [1 2 3 4 5 6]
B) [1 2 3 4 5]
C) [0 1 2 3 4 5 6]
D) None of the mentioned above
Question 81

Which of the following types of loops are not supported in Python?
निम्नलिखित में से किस प्रकार के लूप पायथन में समर्थित नहीं हैं?

A) for
B) while
C) do-while
D) none
Question 82

What will be the output of the following Python code?

        def maximum(x, y): 
            if x>y:
                return x
            elif x==y:
                return 'The numbers are equal'
            else:
                return y
        print(maximum(2, 3))
A) 2
B) 3
C) The numbers are equal
D) None of the mentioned
Question 83

What will be the output of the following Python code?

        def f1(a,b=[]):
            b.append(a)
            return b
        print(f1(2,[3, 4]))
A) [3,2,4]
B) [2,3,4]
C) [3,4,2]
D) Error
Question 84

What will be the following code output?

        import numpy as np
        arr=np.array([10,20,30,40,50])
        print(arr[arr>30])
A) [30,40,50]
B) [10,20]
C) [40,50]
D) Error: Invalid comparison

Report Card

Total Questions Attempted: 0

Correct Answers: 0

Wrong Answers: 0

--