Blog - Python Quiz 2

Python Quiz 2

Python Quiz 2

Python

 

1. Which data structure in Python is used to store an ordered collection of items with no duplicates? 

पायथन में किस डेटा संरचना का उपयोग बिना डुप्लिकेट वाले आइटमों के ऑर्डर किए गए संग्रह को संग्रहीत करने के लिए किया जाता है?

a) Set

b) List

c) Tuple

d) Dictionary 

2.  What is the purpose of the break statement in a loop in Python? 

पायथन में लूप में ब्रेक स्टेटमेंट का उद्देश्य क्या है?

a) To exit the loop and continue to the next iteration

b) To exit the loop entirely

) To skip the current iteration and continue to the next

) To create a loop

 

3.What is the purpose of the continue statement in a loop in Python?

पायथन में लूप में जारी कथन का उद्देश्य क्या है?

a) To exit the loop and continue to the next iteration

b) To exit the loop entirely

c) To skip the current iteration and continue to the next

d) To create a loop

 

4. Which built-in function is used to find the maximum value in a Python list?

पायथन सूची में अधिकतम मान ज्ञात करने के लिए किस अंतर्निहित फ़ंक्शन का उपयोग किया जाता है?

a) max()

b) maximum()

c) find_max()

d) largest() 

 

5. In Python, how do you open a file in binary mode?

पायथन में, आप किसी फ़ाइल को बाइनरी मोड में कैसे खोलते हैं?

) open("file.txt", "r")

b) open("file.txt", "b")

c) open("file.txt", "w")

d) open("file.txt", "x")

 

6. What is the purpose of the with statement in Python when working with files? 

फ़ाइलों के साथ काम करते समय पायथन में with कथन का उद्देश्य क्या है?

a) To open a file in write mode

b) To create a new file

c) To automatically close the file after its suite finishes executing

d) To rename a file

 

7. What is a lambda function in Python, and why is it useful?

पायथन में लैम्ब्डा फ़ंक्शन क्या है और यह उपयोगी क्यों है?

) A lambda function is a function with a long name

) A lambda function is a predefined function in Python

c) A lambda function is an anonymous function that can be used for small, one-time operations

d) A lambda function is a function that cannot be used in Python 

 

8.How do you remove all elements from a Python list?

आप पायथन सूची से सभी तत्वों को कैसे हटाते हैं?

a) Using the clear() method

b) Using the delete() method

c) Using the remove_all() method

) Using the pop_all() method  

 

9. What is the purpose of the set() data type in Python? 

पायथन में सेट() डेटा प्रकार का उद्देश्य क्या है?

a) To store an ordered collection of items with duplicates

b) To store an ordered collection of items with no duplicates

) To store key-value pairs

d) To store a sequence of characters  

 

10.What is the result of "Hello" * 3 in Python?

पायथन में "हैलो"*3 का परिणाम क्या है?

a) "HelloHelloHell

b) "Hello3"

c) Error

d) None of the above  

 

11. How do you define a global variable in Python?

आप पायथन में वैश्विक चर को कैसे परिभाषित करते हैं?

a) By declaring it within a function

b) By using the global keyword

c) Global variables are automatically defined in Python

d) Global variables cannot be defined in Python

12.What is the purpose of the else block in a Python try and except statement?

पाइथॉन ट्राई और सिवाय स्टेटमेंट में अन्य ब्लॉक का उद्देश्य क्या है? 

a) To define a function

b) To create a loop

) To handle the exception if it occurs

) To execute a block of code if no exception occurs 

 

13. What is the purpose of the finally block in a Python try and except statement? 

पाइथॉन ट्राई एंड एक्सेप्ट स्टेटमेंट में अंततः ब्लॉक का उद्देश्य क्या है?

) To define a function

b) To create a loop

c) To handle the exception if it occurs

) To execute a block of code regardless of whether an exception occurs or not 

  

14. What is the output of print("Python"[::-1]) in Python?

पायथन में print('Python'[::-1]) का आउटपुट क्या है?

) "nohtyP"

b) "Python"

c) Error

) None of the above  

 

15. How do you remove the last element from a Python list?

आप पायथन सूची से अंतिम तत्व को कैसे हटाते हैं?

a) Using the remove_last() method

b) Using the pop() method with no arguments

c) Using the delete_last() method

d) Using the clear() method 

 

16. What is the result of "Python".upper() in Python?

Python में "Python.upper() का परिणाम क्या है?

a) "PYTHON"

) "python"

) "PyThOn"

d) "PYT"

 

17. Which operator is used for string concatenation in Python?

पायथन में स्ट्रिंग कॉन्सटेनेशन के लिए किस ऑपरेटर का उपयोग किया जाता है?

a) +

b) *

c) /

d) -  

 

18. What is the purpose of the enumerate() function in Python?

पायथन में enumerate() फ़ंक्शन का उद्देश्य क्या है?

a) To count the number of elements in a list

b) To create a list from a sequence of numbers

c) To iterate over both the index and value of elements in an iterable

d) To remove elements from a list 

 

19. Which built-in function is used to find the minimum value in a Python list?

पायथन सूची में न्यूनतम मान ज्ञात करने के लिए किस अंतर्निहित फ़ंक्शन का उपयोग किया जाता है?

a) min()

b) minimum()

c) find_min()

d) smallest()  

 

20. How do you check if a value is in a Python list?

आप कैसे जांचते हैं कि कोई मान पायथन सूची में है या नहीं?

a) Using the contains() method

b) Using the in keyword

c) Using the exists() method

d) Using the has() method 

 

21. What is the result of 3 // 2 in Python?

पायथन में 3//2 का परिणाम क्या है?

a) 1.5

b) 1

c) 2.0

d) 2 

 

22. What is the purpose of the ord() function in Python?

पायथन में ऑर्ड() फ़ंक्शन का उद्देश्य क्या है?

a) To find the average of a list of numbers

b) To convert a character to its ASCII code

c) To convert a number to its hexadecimal representation

d) To calculate the length of a string  

 

23. How do you check the data type of a variable in Python?

आप पायथन में किसी वेरिएबल के डेटा प्रकार की जांच कैसे करते हैं?

a) Using the typeof() function

b) Using the type() function

c) Using the datatype() method

d) Using the is_type() method 

 

24. What is the result of "Hello".replace("l", "X") in Python?

पाइथॉन में "Hello"।replace("l", "X") का परिणाम क्या है?

a) "Hello"

b) "Hexxo"

c) "HeXXo"

d) "XeXXo" 

 

25. What is the output of print(2 ** 3) in Python?

पायथन में प्रिंट(2 ** 3) का आउटपुट क्या है?

 

a) 6

b) 8

c) 23

d) None of the above

 

 

 

 


112 10 months ago