Blog - Python Quiz 1

Python Quiz 1

Python Quiz 1

Python
1.  What type of language is Python?

पाइथॉन किस प्रकार की भाषा है?

a) Compiled

b) Interpreted

c) Both compiled and interpreted

d) None of the above 

 

2.  Which of the following is NOT a Python data type?

निम्नलिखित में से कौन सा पायथन डेटा प्रकार नहीं है?

a) int

b) float

c) string

d) char 

 

3. How do you indicate a comment in Python?

आप पायथन में किसी टिप्पणी को कैसे इंगित करते हैं?

a) // This is a comment

b) # This is a comment

c) /* This is a comment */

d) <!-- This is a comment -->

 

4. In Python, which keyword is used to define a function?

पायथन में, किसी फ़ंक्शन को परिभाषित करने के लिए किस कीवर्ड का उपयोग किया जाता है?

a) func

b) define

c) function

d) def

 

5. What is the output of print(2 * 3)?

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

a) 5

b) 6

c) 2*3

d) 23

 

6. Which of the following is a valid variable name in Python?

निम्नलिखित में से कौन सा पायथन में एक वैध चर नाम है?

a) 123_variable

b) _variable123

c) variable-123

d) variable 123

 

7. What does the len() function in Python do?

पायथन में len() फ़ंक्शन क्या करता है?

a) Returns the length of a string or a sequence

b) Converts a string to lowercase

c) Returns the largest number in a list

d) Converts a string to uppercase 

 

8. Which data structure in Python is ordered, changeable, and allows duplicate values?

पायथन में कौन सी डेटा संरचना क्रमबद्ध, परिवर्तनशील और डुप्लिकेट मानों की अनुमति देती है?

a) List

b) Tuple

c) Set

d) Dictionary 

 

9. How do you define a tuple in Python?

आप पायथन में टुपल को कैसे परिभाषित करते हैं?

a) (1, 2, 3)

b) [1, 2, 3]

c) {1, 2, 3}

d) {"one": 1, "two": 2, "three": 3} 

 

10. Which operator is used for exponentiation in Python?

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

a) ^

b) **

c) %

d) &

 

11. What is the result of 5 == 5.0 in Python?

पायथन में 5 == 5.0 का परिणाम क्या है?

a) True

b) False

c) Error

d) None of the above

 

12. What is the output of print("Hello" + "World") in Python?

पायथन में प्रिंट ("हैलो" + "वर्ल्ड") का आउटपुट क्या है?

a) HelloWorld

b) Hello World

c) Hello + World

d) Error 

 

13. What is the purpose of an "if" statement in Python?

पायथन में "if" स्टेटमेंट का उद्देश्य क्या है?

a) To create a loop

b) To define a function

c) To execute code conditionally

d) To print output

 

14. How do you open a file in Python for reading?

आप पढ़ने के लिए पायथन में एक फ़ाइल कैसे खोलते हैं?

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

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

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

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

 

15. Which module in Python is used for working with dates and times?

पायथन में किस मॉड्यूल का उपयोग दिनांक और समय के साथ काम करने के लिए किया जाता है?

a) time

b) datetime

c) date

d) calendar 

 

16. What is the output of print("Python"[2:4]) in Python?

पायथन में प्रिंट('पायथन'[2:4]) का आउटपुट क्या है?

a) Py

b) th

c) Pyt

d) thon

 

17. How do you define a function in Python with no parameters?

आप पायथन में बिना किसी पैरामीटर वाले फ़ंक्शन को कैसे परिभाषित करते हैं?

a) def my_function:

b) def my_function():

c) def my_function(param1, param2):

d) def my_function(param1): 

 

18. What is the purpose of the return statement in a Python function?

पायथन फ़ंक्शन में रिटर्न स्टेटमेंट का उद्देश्य क्या है?

a) To define a variable

b) To print output

c) To exit the function and return a value

d) To create a loop

 

19. Which Python keyword is used to create a loop?

लूप बनाने के लिए किस पायथन कीवर्ड का उपयोग किया जाता है?

a) for

b) loop

c) while

d) until 

 

20. How do you check if a key exists in a Python dictionary?

आप कैसे जांचेंगे कि पाइथॉन डिक्शनरी में कोई कुंजी मौजूद है या नहीं?

a) Using the has_key() method

b) Using the contains() method

c) Using the in keyword

d) Using the exists() method 

 

21. What is the output of print("Hello, {}!".format("John")) in Python?

पायथन में print("Hello, {}!".format("John")) का आउटपुट क्या है?

a) Hello, John!

b) Hello, {}!

c) Hello, {John}!

d) Error 

 

22. Which of the following is a valid way to import a module in Python?

निम्नलिखित में से कौन सा पायथन में मॉड्यूल आयात करने का वैध तरीका है?

a) import math

b) include math

c) require math

d) load math

 

23. What is the purpose of the try and except blocks in Python?

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

a) To define a function

b) To create a loop

c) To handle exceptions and errors

d) To perform mathematical operations

 

24. How do you remove an item from a list in Python?

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

a) Using the remove() method

b) Using the discard() method

c) Using the delete() method

d) Using the pop() method

 

25. What is the result of 5 / 2 in Python?

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

a) 2.5

b) 2

c) 2.0

d) Error 

 

 


150 11 months ago