CS118 Final Exam

Ace your homework & exams now with Quizwiz!

1- Is Python code compiled or interpreted? a) Python code is both compiled and interpreted b) Python code is neither compiled nor interpreted c) Python code is only compiled d) Python code is only interpreted

a

The following python program can work with ____ parameters. def f(x): def f1(*args, **kwargs): print("Sanfoundry") return x(*args, **kwargs) return f1 a) any number of b) 0 c) 1 d) 2

a

What are the values of the following Python expressions? 2**(3**2) (2**3)**2 2**3**2 a) 512, 64, 512 b) 512, 512, 512 c) 64, 512, 64 d) 64, 64, 64

a

What will be the output of the following Python code snippet? for i in [1, 2, 3, 4][::-1]: print (i) a) 4 3 2 1 b) error c) 1 2 3 4 d) none of the mentioned

a

What will be the output of the following Python code? class tester: def __init__(self, id): self.id = str(id) id="224" temp = tester(12) print(temp.id) a) 12 b) 224 c) None d) Error

a

What will be the output of the following Python code? print("abc. DEF".capitalize()) a) Abc. def b) abc. def c) Abc. Def d) ABC. DEF

a

What will be the value of ‘result’ in following Python program? list1 = [1,2,3,4] list2 = [2,4,5,6] list3 = [2,6,7,8] result = list() result.extend(i for i in list1 if i not in (list2+list3) and i not in result) result.extend(i for i in list2 if i not in (list1+list3) and i not in result) result.extend(i for i in list3 if i not in (list1+list2) and i not in result) a) [1, 3, 5, 7, 8] b) [1, 7, 8] c) [1, 2, 4, 7, 8] d) error

a

What will be the output of the following Python statement? >>>"a"+"bc" a) bc b) abc c) a d) bca

b

Which keyword is used for function in Python language? a) Function b) def c) Fun d) Define

b

Which of the following character is used to give single-line comments in Python? a) // b) # c) ! d) /*

b

Which of the following functions is a built-in function in python? a) factorial() b) print() c) seed() d) sqrt()

b

Which of the following is the truncation division operator in Python? a) | b) // c) / d) %

b

Which of the following is true for variable names in Python? a) underscore and ampersand are the only two special characters allowed b) unlimited length c) all private members must have leading and trailing underscores d) none of the mentioned

b

Which one of the following is not a keyword in Python language? a) pass b) eval c) assert d) nonlocal

b

3- Which one of the following is the use of function in python? a) Punctions donae™t provide better modularity for your application b) you canãe™t also create your own functions c) Functions are reusable pieces of programs dy All of the mentioned

c

To add a new element to a list we use which Python command? a) list1.addEnd(5) b) list1.addLast(5) c) list1.append(5) d) list1.add(5)

c

What are the two main types of functions in Python? a) System function b) Custom function c) Built-in function & User defined function d) User function

c

What will be the output of the following Python code? >>>list1 = [1, 3] >>>list2 = list1 >>>list1[0] = 4 >>>print(list2) a) [1, 4] b) [1, 3, 4] c) [4, 3] d) [1, 3]

c

What will be the output of the following Python code? l=[1, 0, 2, 0, 'hello', '', []] list(filter(bool, l)) a) [1, 0, 2, ‘hello’, â€, []] b) Error c) [1, 2, ‘hello’] d) [1, 0, 2, 0, ‘hello’, â€, []]

c

What will be the output of the following Python function? len(["hello",2, 4, 6]) a) Error b) 6 c) 4 d) 3

c

What will be the output of the following Python program? i = 0 while i < 5: print(i) i += 1 if i == 3: break else: print(0) a) error b) 0 1 2 0 c) 0 1 2 d) none of the mentioned

c

Which of the following is not a core data type in Python programming? a) Tuples b) Lists c) Class d) Dictionary

c

2- What will be the output of the following Python code? x = [[0] , [1]] print (( ' ' .join(list(map(str, x))),)) a) 01 b) (01 (1) c) (6€™016€*) d) (a€ (0) (1jãe",)

d

All keywords in Python are in _________ a) Capitalized b) lower case c) UPPER CASE d) None of the mentioned

d

What is the maximum possible length of an identifier(Index or List) in Python? a) 79 characters b) 31 characters c) 63 characters d) none of the mentioned

d

What is the order of precedence in python? a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction c) Parentheses, Exponential, Multiplication, Division, Subtraction, Addition d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction

d

What will be the output of the following Python expression if x=56.236? print("%.2f"%x) a) 56.236 b) 56.23 c) 56.0000 d) 56.24 View Answer

d

What will be the output of the following Python function? min(max(False,-3,-4), 2,7) a) -4 b) -3 c) 2 d) False

d

What will be the output of the following Python program? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q)) a) Error b) None c) False d) True

d

Which of the following statements is used to create an empty set in Python? a) ( ) b) [ ] c) { } d) set()

d


Related study sets

Entrepreneurship Quizzes (Midterm Review)

View Set

Ch 20 Magnetism and Ch 21 EM Induction

View Set

Chapter 12 Capacity and Legality - DONE

View Set

2.11 Unit Test: The Power of Language

View Set

Chapter 1 and 2 Databases and SQL

View Set