Python Questions

0 votes, 0 avg
39

Python Questions

1 / 15

1. What will be the output of the following code snippet?

a = 3
b = 1 
print(a, b)
a, b = b, a 
print(a, b)

2 / 15

2.  Python supports the creation of anonymous functions at runtime, using a construct called __________

3 / 15

3. What will be the output of the following Python program?

    def addItem(listParam):

        listParam += [1]

     

    mylist = [1, 2, 3, 4]

    addItem(mylist)

    print(len(mylist))

4 / 15

4. What is Instantiation in terms of OOP terminology?

5 / 15

5. What will be the output of the following Python code?

    def C2F(c):

        return c * 9/5 + 32

    print C2F(100)

    print C2F(0)

6 / 15

6. Which of the following best describes inheritance?

7 / 15

7. Which of the following Python code will print True?

a = foo(2)
b = foo(3)
print(a < b)

8 / 15

8. Which of these about a frozenset is not true?

9 / 15

9. What happens if the file is not found in the following Python code?

a=False
while not a:
    try:
        f_n = input("Enter file name")
        i_f = open(f_n, 'r')
    except:
        print("Input file not found")

10 / 15

10. Consider the results of a medical experiment that aims to predict whether someone is going to develop myopia based on some physical measurements and heredity. In this case, the input dataset consists of the person’s medical characteristics and the target variable is binary: 1 for those who are likely to develop myopia and 0 for those who aren’t. This can be best classified as

11 / 15

11. In Python, ___ defines a block of statements.

12 / 15

12. Let A and B be objects of class Foo. Which functions are called when print(A + B) is executed?

13 / 15

13. What keyword is used in Python to throw exceptions?

14 / 15

14. Which of the following counts the number of elements in Numpy array ?

15 / 15

15. What will be the output of the following Python code?

string = "my name is x"
for i in string.split():
    print (i, end=", ")

Your score is

The average score is 34%

0%