What is python?
A. a code
B. nothing
C. a game
D. a programming language ** Answ** D. a programming language
Which of the following variables is the "most mnemonic"?
A. x
B. x1q3z9ocd
C. hours
D. variable_173 ** Answ** C. hours
Which data structure is being put to use in the code given below?
# Code starts
org = 'QuizOrbit'
count = {}
for i in org:
if i in count:
count[i]+=1
else:
count[i]=1
print(count)
# Code Ends
A. String
B. List
C. Tuple
D. Dictionary ** Answ** D. Dictionary
Which Of The Following Define The Set {'a', 'b', 'c'}:
A. s = {'a', 'b', 'c'}
B. s = set('a', 'b', 'c')
C. s = set('abc')
D. s = set(['a', 'b', 'c'])
E. s = {('a', 'b', 'c')} ** Answ** A. s = {'a', 'b', 'c'}
C. s = set('abc')
D. s = set(['a', 'b', 'c'])
What Python expression tests whether the string 'foo' is a member of set s? ** Answ**
'foo' in s
,You have a set s defined as follows:
s = {100, 200, 300}
Which one of the following statements does not correctly produce the union of s and the
set {300, 400, 500}:
A. s | [300, 400, 500]
B. s | {300, 400, 500}
C. s | ({300, 400, 500})
D. s | set([300, 400, 500])
E. s.union([300, 400, 500])
F. s.union(set([300, 400, 500])) ** Answ** A. s | [300, 400, 500]
What is the result of this statement:
{'b', 'a', 'r'} & set('qux')
A. {'b', 'r', 'a'}
B. {'q', 'r', 'x', 'u', 'b', 'a'}
C. {}
D. set() ** Answ** D. set()
What is the result of this statement:
{1, 2, 3, 4, 5} - {3, 4} ^ {5, 6, 7}
A. {1, 2, 6, 7}
B. set()
C. {1, 2}
D. {3, 4, 5, 6, 7} ** Answ** A. {1, 2, 6, 7}
Consider the following expression involving two sets x and y:
(x & y <= x) and (x & y <= y)
This expression is True for any sets x and y—true or false?
A. False
B. True ** Answ** B. True
What is the result of the highlighted expression:
>>> x = {1, 2, 3}
>>> y = {1, 2}
>>> persubset(x)
A. It raises an exception.
B. set()
C. True
D. False ** Answ** A. It raises an exception.
Suppose a set s is defined as follows:
s = {'foo', 'bar', 'baz', 'qux'}
Which of the following remove element 'bar' from s:
,A. s -= {'bar'}
B. s &= {'foo', 'baz', 'qux'}
C. s.discard('bar')
D. s.pop()
E. del s['bar']
F. s.difference_update({'bar'}) ** Answ** A. s -= {'bar'}
B. s &= {'foo', 'baz', 'qux'}
C. s.discard('bar')
F. s.difference_update({'bar'})
Which of the following are true for objects of Python's set type:
A. The order of elements in a set is significant.
B. A given element can't appear in a set more than once.
C. A set may contain elements that are mutable.
D. Sets are mutable. ** Answ** B. A given element can't appear in a set more than
once.
D. Sets are mutable.
What will be the output of above Python code?
str1="6/4"
print("str1")
A. 1
B. 6/4
C. 1.5
D. str1 ** Answ** D. str1
Which of the following will result in an error?
str1="python"
A. print(str1[2])
B. str1[1]="x"
C. print(str1[0:9])
D. Both (b) and (c) ** Answ** B. str1[1]="x"
What will be the output of below Python code?
str1="Information"
print(str1[2:8])
A. format
B. formatio
C. orma
D. ormat ** Answ** A. format
What will be the output of below Python code?
, str1="Aplication"
str2=str1.replace('a','A')
print(str2)
A. application
B. Application
C. ApplicAtion
D. applicAtion ** Answ** C. ApplicAtion
What is a correct syntax to output "Hello World" in Python?
A. print("Hello World")
B. echo("Hello World");
C. p("Hello World")
D. echo "Hello World" ** Answ** A. print("Hello World")
What will be the output of below Python code?
str1="poWer"
str1.upper()
print(str1)
A. POWER
B. Power
C. power
D. poWer ** Answ** D. poWer
What will the below Python code will return? If
str1="save paper,save plants"
str1.find("save")
A. It returns the index position of the last occurance of "save" in the given string str1.
B. It returns the last index position of the last occurance of "save" in the given string
str1.
C. It returns the last index position of the first occurance of "save" in the given string
str1.
D. It returns the first index position of the first occurance of "save" in the given string
str1. ** Answ** D. It returns the first index position of the first occurance of "save" in
the given string str1.
Which of the following will give "Simon" as output?
If str1="John,Simon,Aryan"
A. print(str1[-7:-12])
B. print(str1[-11:-7])