Professional Documents
Culture Documents
Yes
No
2. How to output the string “May the odds favor you” in Python?
int a = 22.6
a = 22.6
Integer a = 22.6
/* This is comment */
!! This is comment
// This is comment
# This is comment
2.615E8
261500000
261.5E8
2.6
3 + 2j
-100j
5j
lowercase()
capilaize()
lower()
toLower()
9. How to access substring “Kevin” from the following string declaration in Python:
1
2 str = "My name is Kevin"
3
str[11:16]
str(11:16)
str[11][16]
str[11-16]
10. Which of the following is the correct way to access a specific character. Let’s say we need to access
the character “K” from the following string in Python?
1
3
str(11)
str[11]
str:9
11. Which Python module is used to parse dates in almost any string format?
datetime module
time module
calendar module
dateutil module
12. Which of the following is the correct way to indicate Hexadecimal Notation in Python?
str = ‘\62’
str = ’62’
str = “62”
str = ‘\x62’
13. To begin slicing from the end of the string, which of the following is used in Python?
Indexing
Negative Indexing
Escape Characters
[:]
in operator
[]
uppercase() method
capitalize() method
upper() method
16. What is the correct way to get maximum value from Tuple in Python?
print (max(mytuple));
print (maximum(mytuple));
print (mytuple.max());
print (mytuple.maximum);
17. How to fetch and display only the keys of a Dictionary in Python?
print(mystock.keys())
print(mystock.key())
print(keys(mystock))
print(key(mystock))
align() method
center() method
fill() method
19. How to access value for key “Price” in the following Python Dictionary:
1
2 mystock = {
3 "Product": "Earphone",
4 "Price": 800,
5 "Quantity": 50,
6 "InStock" : "Yes"
7}
8
mystock[“Product”]
mystock(“Product”)
mystock[Product]
mystock(Product)
expandtabs(6)
tabs(6)
expand(6)
21. ___________ uses square brackets for comma-separated values in Python? Fill in the blanks with a
Python collection?
Lists
Dictionary
Tuples
TRUE
FALSE
23. How to find the index of the first occurrence of a specific value “i”, from string “This is my
website”?
str.find(“i”)
str.find(i)
str.index()
str.index(“i”)
24. How to display whether the date is AM/PM in Python?
25. Which of the following is the correcy way to access a specific element from a Multi-Dimensional
List?
list[row_size:column_size]
list[row_size][column_size]
list[(row_size)(column_size)]
26. Which of the following Bitwise operators in Python shifts the left operand value to the right, by
the number of bits in the right operand. The rightmost bits while shifting fall off?
27. How to specify range of index in Python Tuples? Let’s say our tuple name is “mytuple”
print(mytuple[1:4])
print(mytuple[1 to 4])
print(mytuple[1-4])
print(mytuple[].slice[1:4])
28. How to correctly create a function in Python?
demoFunction()
def demoFunction()
function demoFunction()
void demoFunction()
str = “demo666”
str = “666”
str = “$$$666”
print() method
printable() method
isprintable() method
echo() method
31. How to delete an element in a Dictionary with a specific key. Let’s say we need to delete the key
“Price”
del dict[‘Price’]
del.dict[‘Price’]
del dict(‘Price’)
del.dict[‘Price’]
32. How to swap case in Python i.e. lowercase to uppercase and vice versa?
casefold() method
swapcase() method
case() method
title() method
Define a list
Define an array
Define a Dictionary
34. Which of the following is used to empty the Dictionary in Python? Let’s say our dictionary name is
“mystock”.
mystock.del()
clear mystock
del mystock
mystock.clear()
date.strftime(“%j”)
date.strftime(“%H”)
date.strftime(“%I”)
date.strftime(“%p”)
36. What is used in Python functions, if you have no idea about the number of arguments to be
passed?
Keyword Arguments
Default Arguments
Required Arguments
Arbitrary Arguments
38. In Python Functions, what is to be used to skip arguments or even pass them in any order while
calling a function?
Keyword arguments
Default Arguments
Required Arguments
Arbitrary Arguments
count() method
length() method
len() method
mytuple(1)
mytuple{1}
mytuple[1]
Keyword Arguments
Default Arguments
42. How to convert the lowercase letters in the string to uppercase in Python?
upper()
uppercase()
capitalize()
toUpper()
43. What is the correct way to get minimum value from a List in Python?
print (minimum(mylist));
print (min(mylist));
print (mylist.min());
print (mylist.minimum());
Yes
No
45. Which of the following correctly converts int to float in Python?
res = float(10)
res = convertToFloat(10)
print(typeOf(a))
print(typeof(a))
print(type(a))
47. How to compare two operands in Python and check for equality? Which operator is to be used?
=
in operator
is operator
== (Answer)
48. What is the correct way to get minimum value from Tuple?
print (min(mytuple));
print (minimum(mytuple));
print (mytuple.min());
print (mytuple.minimum);
date.strftime(“%H”)
date.strftime(“%I”)
date.strftime(“%p”)
date.strftime(“%m”)
50. How to compare two objects and check whether they have same memory locations?
is operator
in operator
**
Bitwise operators
51. How to fetch and display only the values of a Dictionary in Python?
print(mystock.value())
print(mystock.values())
print(values(mystock))
print(value(mystock))
Bitwise Operators
TRUE
FALSE
54. ____________ represents key-value pair in Python?
Tuples
Lists
Dictionary
55. Which of the following Bitwise operators sets each bit to 1, if only one of them is 1, i.e. if only one
of the two operands are 1.
Bitwise XOR
Bitwise OR
Bitwise AND
Bitwise NOT
56. What is the correct way to get maximum value from a List in Python?
print (maximum(mylist));
print (mylist.max());
print (max(mylist));
print (mylist.maximum());
57. An example to correctly begin searching from the end range of index in Python Tuples. Let’s say
our Python Tuple has 4 elements
print(mytuple[-3 to -1])
print(mytuple[3-1])
print(mytuple[].slice[-3:-1])
print(mytuple[-3:-1])
58. Which of the following Bitwise operators in Python shifts the left operand value to the left, by the
number of bits in the right operand. The leftmost bits while shifting fall off.
59. Can we update Tuples or any of its elements in Python after assignment?
Yes
No
date.strftime(“%H”)
date.strftime(“%B”)
date.strftime(“%m”)
date.strftime(“%d”)
61. ___________ uses Parenthesis for comma-separated values in Python? Fill in the blanks with a
Python collection?
List
Tuples
mytuple = ()
mytuple = (0)
mytuple = 0
mytuple =
TRUE
FALSE
TRUE
FALSE
65. What is the correct way to create a list with type float?
date.strftime(“%j”)
date.strftime(“%H”)
date.strftime(“%I”)
date.strftime(“%p”)
del mylist(2:4)
del mylist[2 to 4]
del mylist(2 to 4)
68. How to fetch last element from a Python List with negative indexing?
69. What is the correct way to get the length of a List in Python?
mylist.count()
count(mylist)
len(mylist)
length(mylist)
calendar module
datetime module
dateutil module