Question 1
Question
1. What is the output of print str if str = 'Hello World!'?
Answer
-
Hello World
-
Hello World!
-
World
-
‘Hello World!’
Question 2
Question
What is the output of print str * 2 if str = 'Hello World!'?
Question 3
Question
Which of the following is correct about dictionaries in python?
Answer
-
Python's dictionaries are kind of hash table type
-
They work like associative arrays or hashes found in Perl and consist of key-value pairs
-
A dictionary key can be almost any Python type, but are usually numbers or strings. Values, on the other hand, can be any arbitrary Python object
-
All of the above
Question 4
Question
What is the output of print tinylist * 2 if tinylist = [123, 'john']?
Question 5
Question
What is the output of print str[2:] if str = 'Hello World!'?
Answer
-
llo World!
-
H
-
llo
-
Hello World!
Question 6
Question
What is the output of len([1, 2, 3])?
Question 7
Question
What is the output of print str * 2 if str = 'Hello World!'?
Answer
-
Hello World!Hello World!
-
Hello World! * 2
-
error
-
2
Question 8
Question
Which of the following function convert an integer to a character in python?
Answer
-
set(x)
-
dict(d)
-
frozenset(s)
-
chr(x)
Question 9
Question
Which of the following function checks in a string that all characters are in lowercase?
Answer
-
islower()
-
isnumeric()
-
isspace()
-
istitle()
Question 10
Question
Which of the following function returns the max alphabetical character from the string str?
Answer
-
lower()
-
lstrip()
-
max(str)
-
min(str)
Question 11
Question
Which of the following is correct about Python?
Answer
-
It supports functional and structured programming methods as well as OOP.
-
It can be used as a scripting language or can be compiled to byte-code for building large applications.
-
It provides very high-level dynamic data types and supports dynamic type checking.
-
All of the above
Question 12
Question
What is the output of L[1:] if L = [1,2,3]?
Answer
-
2,3
-
2
-
3
-
None of the above.
Question 13
Question
What is the output of L[-2] if L = [1,2,3]?
Question 14
Question
What is the following function sorts a list?
Answer
-
list.reverse()
-
list.sort()
-
list.pop(obj=list[-1])
-
list.remove(obj)
Question 15
Question
State the output that would be produced from the following statement, when written in Python code: print “3”+”3”
Question 16
Question
State the output that would be produced from the following statement, when written in Python code: print 3+3
Question 17
Question
State the output that would be produced from the following statement, when written in Python code: print “3” * 3
Question 18
Question
What is the output of print str[2:5] if str = 'Hello World!'?
Answer
-
llo World!
-
H
-
llo
-
None of the above.
Question 19
Question
Which of the following function converts a string to all uppercase?
Answer
-
upper()
-
isdecimal()
-
swapcase()
-
title()
Question 20
Question
Which of the following function converts a string to all lowercase?
Answer
-
upper()
-
isdecimal()
-
lower()
-
title()
Question 21
Question
Functions must be defined first ____________ they can be called
Answer
-
Before
-
After
-
Between
-
At the same time
Question 22
Question
What is the output of for x in [1, 2, 3]: print x?
Question 23
Question
What is the output when following statement is executed print “a”+ “bc” ?
Question 24
Question
What is the output when we execute print (list("hello"))?
Answer
-
[‘h’, ’e’, ’l’, ‘l’, ‘o’]
-
[‘hello’]
-
[‘llo’]
-
{‘hello’}
Question 25
Question
What is the output from the following code str1="helloworld", str1[::-1]?
Answer
-
dlrowolleh
-
hello
-
world
-
helloworld
Question 26
Question
Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?
Answer
-
[2, 33, 222, 14]
-
Error
-
25
-
[25, 14, 222, 33, 2]
Question 27
Question
Which of the following is a Python tuple?
Answer
-
[1, 2, 3]
-
(1, 2 ,3)
-
{1, 2, 3}
-
{}
Question 28
Question
Is Python case sensitive when dealing with identifiers?
Question 29
Question
Which of the following cannot be a variable?
Question 30
Question
Supports ‘Last in, first out’ ordering of data
Answer
-
Queue
-
Stack
-
Tuple
-
Dictionary
Question 31
Question
Which of the following is correct output of “print type(1/2)”?
Answer
-
<type 'int'>.
-
<type 'number'>
-
<type 'float'>
-
<type 'double'>
-
<type 'tuple'>
Question 32
Question
Which of the following is correct output of “print type([1,2])”?
Answer
-
<type 'list'>
-
<type 'number'>
-
<type 'float'>
-
<type 'double'>
-
<type 'tuple'>
Question 33
Question
Which of the following is correct output of “import math print(math.floor(5.6))”?
Question 34
Question
Which of the following is correct output of “colors = [‘Red’, ‘Black’, ‘White’, ‘Green’] x = colors.index(“White”) print(x)”?
Question 35
Question
Which of the following is correct output of “x = 12 y = 18 x = y y = x print(x,y)”?
Question 36
Question
Which of the following is correct output of “x = ‘abcd’ y = 10 print(x+y)”?
Question 37
Question
Which of the following is correct output of “colors = [‘Red’, ‘Black’, ‘White’, ‘Green’] print(colors[-2][-2])”?
Question 38
Question
Which of the following statement is Python comment?
Answer
-
*This is a Python comment
-
#This Is a Python comment
-
none of the above
-
//This is a Python comment
Question 39
Question
Which of the following code will add a new color ‘Black’ at the end of the list?
Answer
-
colors.insert('black')
-
colors.add('black')
-
colors.append('black')
-
colors+=('black')
Question 40
Question
Which of the following expression is called for an user input?
Answer
-
input
-
read
-
none of the above
-
for
Question 41
Question
Which of the following is correct output of “colors = [‘red’, ‘white’, ‘Blue’, ‘green’] print(colors[-2])?
Answer
-
'white'
-
'blue'
-
'red'
-
'green'
Question 42
Question
Which of the following is correct output of “print(type([1,2,3]))”?
Answer
-
<class 'list'>
-
<class 'tuple'>
-
<class 'set'>
-
<class 'type'>
Question 43
Question
Which of the following is correct about Python?
Answer
-
python is a high-level, interpreted, interactive and object-oriented scripting language
-
python is designed to be highly readable
-
it uses English keywords frequently where as other languages use punctuation, and it has fewer syntactical constructions than other languages
-
all Of The Above
Question 44
Question
Is python a case sensitive language?
Question 45
Question
Which of the following data types is not supported in python?
Answer
-
numbers
-
string
-
list
-
slice
Question 46
Question
Which of the following data types is not supported in python?
Answer
-
tuple
-
dictionary
-
generics
-
list
Question 47
Question
What is the output of print str if str = 'Hello World!'?
Answer
-
Hello World!
-
error
-
str
-
none of the above
Question 48
Question
What is the output of print str[0] if str = 'Hello World!'?
Answer
-
Hello World!
-
H
-
ello World!
-
str
Question 49
Question
What is the output of print str[2:5] if str = 'Hello World!'?
Answer
-
Hello World!
-
llo World!
-
H
-
llo
Question 50
Question
_________________ in Python are identified as a contiguous set of characters in between quotation marks
Answer
-
numbers
-
strings
-
list
-
tuple
Question 51
Question
What is the output of print list if list = [ 'abcd', 786, 2.23, 'john', 70.2]?
Answer
-
[ 'abcd', 786, 2.23, 'john', 70.2]
-
list
-
error
-
[ 'abcd', 786, 2.23, 'john']
Question 52
Question
What is the output of print list[0] if list = [ 'abcd', 786, 2.23, 'john', 70.2]?
Answer
-
[ 'abcd', 786, 2.23, 'john', 70.2]
-
list
-
error
-
[ 'abcd']
Question 53
Question
What is the output of print list[1:3] if list = [ 'abcd', 786, 2.23, 'john', 70.2]?
Answer
-
[ 'abcd', 786, 2.23, 'john', 70.2]
-
list
-
[786, 2.23, 'john']
-
[ 'abcd']
Question 54
Question
What is the output of print list[2:] if list = [ 'abcd', 786, 2.23, 'john', 70.2]?
Answer
-
[ 'abcd', 786, 2.23, 'john', 70.2]
-
[786, 2.23, 'john', 70.2]
-
[2.23, 'john', 70.2]
-
[ 'abcd']
Question 55
Question
What is the output of print tinylist * 2 if tinylist = [123, 'john']?
Question 56
Question
Which of the following operator in python performs exponential (power) calculation on operands?
Question 57
Question
Which of the following function changes case for all letters in string?
Answer
-
swap(old, new [, max])
-
strip([chars])
-
swapcase().
-
title()
Question 58
Question
What is the output of ['Hi!'] * 4?
Question 59
Question
What is the following function sorts a list?
Answer
-
list.reverse()
-
list.sort([func])
-
list.pop(obj=list[-1])
-
list.remove(obj)
Question 60
Question
Following set of commands are executed in shell, what will be the output? >>>str="Hello" >>>str[:2]
Question 61
Question
What kind of error occurs when you execute the following code apple = mango?
Answer
-
Syntaxerror
-
Nameerror
-
Valueerror
-
Typeerror
Question 62
Question
Select all options that will correctly print “hello-how-are-you”?
Answer
-
print(‘hello’, ‘how’, ‘are’, ‘you’)
-
print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
-
print(‘hello-‘ + ‘how-are-you’)
-
print(‘hello’, ‘how’, ‘are’)
Question 63
Question
What is the answer of this expression, 22 % 3?
Question 64
Question
You can’t perform mathematical operation on String?
Question 65
Question
Operators with the same precedence are evaluated in which manner?
Answer
-
left to right
-
right to left
Question 66
Question
How will you get ‘min’ alphabetical character from the string?
Answer
-
min(str)
-
max(str)
-
min(int)
-
lower()
Question 67
Question
How will you get ‘max’ alphabetical character from the string?
Answer
-
min(str)
-
max(str)
-
min(int)
-
lower()
Question 68
Question
How will you convert a string to all lowercase?
Answer
-
min(str)
-
max(str)
-
min(int)
-
lower()
Question 69
Question
Which of the following is invalid?
Answer
-
_a = 1
-
__a = 1
-
__str__ = 1
-
a% = 1
Question 70
Question
Which of the following is an invalid variable?
Answer
-
my_string_1
-
1st_string
-
foo
-
alua
Question 71
Question
Why are local variable names beginning with an underscore discouraged?
Answer
-
They Are Used To Indicate a Private Variables of a Class
-
They confuse the interpreter
-
They are used to indicate global variables
-
They slow down execution
Question 72
Question
Which of the following is not a keyword?
Answer
-
eval
-
assert
-
nonlocal
-
pass
Question 73
Question
All keywords in Python are in
Answer
-
lower case
-
upper case
-
Capitalized
-
none
Question 74
Question
Which of the following is true for variable names in Python?
Question 75
Question
Which of the following is an invalid statement?
Answer
-
abc = 1,000,000
-
a b c = 1000.2000.3000
-
a,b,c = 1000, 2000, 3000
-
a_b_c = 1,000,000
Question 76
Question
Which of the following cannot be a variable?
Question 77
Question
What does the function re.match do?
Answer
-
Matches a Pattern at the Start of the String
-
matches a pattern at any position in the string
-
such a function does not exist
-
none of the mentioned
Question 78
Question
Which of the following is incorrect?
Answer
-
float(‘inf’)
-
float(‘nan’)
-
float(’56’+’78’)
-
float(’12+34′)
Question 79
Question
Int(x) means variable x is converted to integer
Question 80
Question
Can You perform mathematical operation with String?
Question 81
Question
Which of the following logical operator is correct for definition “If both the operands are true then then condition becomes true”
Answer
-
And
-
No correct answer
-
Not
-
In
Question 82
Question
Which of the following logical operator is correct for definition “If both the operands are false then then condition becomes true”
Answer
-
And
-
No correct answer
-
Not
-
OR
Question 83
Question
Which of the following logical operator is correct for definition “If one of the operands is false, second is true then condition becomes false”
Answer
-
And
-
No correct answer
-
IN
-
OR
Question 84
Question
Which of the following logical operator is correct for definition “If one of the operands is false, second is true then condition becomes true”
Answer
-
And
-
No correct answer
-
IN
-
OR
Question 85
Question
Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true
Question 86
Question
Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true
Question 87
Question
Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true
Question 88
Question
Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true
Question 89
Question
Choose the correct expressing computations definition for “Get data from the keyboard, a file, or some other device”
Answer
-
Input
-
Output
-
Maths
-
Repetition
Question 90
Question
Choose the correct expressing computations definition for “Display data on the screen or send data to a file or other device”
Answer
-
Input
-
Output
-
Maths
-
Repetition
Question 91
Question
Choose the correct expressing computations definition for “Perform basic mathematical operations like addition and multiplication”
Answer
-
Input
-
Output
-
Maths
-
Repetition
Question 92
Question
Choose the correct expressing computations definition for “Check for certain conditions and execute the appropriate code”
Answer
-
Input
-
Output
-
Conditional logic
-
Repetition
Question 93
Question
Choose the correct expressing computations definition for “Perform some action repeatedly, usually with some variation”
Answer
-
Input
-
Output
-
Maths
-
Repetition
Question 94
Question
Choose the correct definition for High level code
Answer
-
Syntax a specific type of computer can understand
-
Also known as Assembly or Machine Code
-
Rare to directly create now
-
Human friendly syntax
Question 95
Question
_________________is a name that refers to a value
Answer
-
Variable
-
Name
-
Value
-
Nothing
Question 96
Question
_______________________is used to create variables and to give them values
Answer
-
Assignment statement
-
Variable
-
Naming
-
Statement
Question 97
Question
We can use the ______________ function to check the type of a variable
Answer
-
Type()
-
Check()
-
Variable()
-
Str()
Question 98
Question
We can alter the type of a variable using the following functions, which is “converts variable to a string”
Answer
-
Type()
-
Int()
-
Float()
-
Str()
Question 99
Question
We can alter the type of a variable using the following functions, which is “converts variable to a integer”
Answer
-
Type()
-
Int()
-
Float()
-
Str()
Question 100
Question
We can alter the type of a variable using the following functions, which is “converts variable to a float”
Answer
-
Type()
-
Int()
-
Float()
-
Str()
Question 101
Question
Choose the keyword that cannot be used as names for variables as they already have a meaning and purpose.
Answer
-
def
-
definition
-
purpose
-
printing
Question 102
Question
Lists are a commonly used, simple compound data type in Python, choose the correct answer for “index starts at 0”
Answer
-
mylist[0]
-
mylist[-1]
-
mylist[2:4]
-
mylist[1]
Question 103
Question
Lists are a commonly used, simple compound data type in Python, choose the correct answer for “reversing from the last value”
Answer
-
mylist[0]
-
mylist[-1]
-
mylist[2:4]
-
mylist[1]
Question 104
Question
Lists are a commonly used, simple compound data type in Python, choose the correct answer for “subset of the values”
Answer
-
mylist[0]
-
mylist[-1]
-
mylist[2:4]
-
mylist[1]
Question 105
Question
in python we use data type, that has keys with values called?
Answer
-
Lists
-
Dictionaries
-
Dairies
-
Compounds
Question 106
Question
There is dictionary called telnumbers = {‘john’: 756, ‘mike’: 789, ‘alex’: 456, ‘sue’: 123}, how to print everything from the dictionary?
Answer
-
print numbers
-
telnumbers
-
telnumbers[‘alex’]
-
telnumbers.keys()
Question 107
Question
There is dictionary called telnumbers = {‘john’: 756, ‘mike’: 789, ‘alex’: 456, ‘sue’: 123}, how to print dictionary keys?
Answer
-
print numbers
-
telnumbers
-
telnumbers[‘alex’]
-
telnumbers.keys()
Question 108
Question
There is dictionary called telnumbers = {‘john’: 756, ‘mike’: 789, ‘alex’: 456, ‘sue’: 123}, how to print Alex’s telephone number?
Answer
-
print numbers[‘alex’]
-
telnumbers
-
telnumbers[‘alex’]
-
telnumbers.keys()
Question 109
Question
There is dictionary called telnumbers = {‘john’: 756, ‘mike’: 789, ‘alex’: 456, ‘sue’: 123}, which of the following is the dictionary key?
Answer
-
‘john’
-
756
-
'alua’
-
numbers.keys
Question 110
Question
There is dictionary called telnumbers = {‘john’: 756, ‘mike’: 789, ‘alex’: 456, ‘sue’: 123}, which of the following is the dictionary value?
Answer
-
‘john’
-
756
-
‘456’
-
numbers.keys
Question 111
Question
choose the correct definition for ‘syntax error’
Answer
-
The structure or tokens in the code are wrong
-
An operation is applied to data of the wrong type
-
Referring to a variable that has not been assigned a value
-
None of the mentioned
Question 112
Question
choose the correct definition for ‘type error’
Answer
-
The structure or tokens in the code are wrong
-
An operation is applied to data of the wrong type
-
Referring to a variable that has not been assigned a value
-
None of the mentioned
Question 113
Question
choose the correct definition for ‘name error’
Answer
-
The structure or tokens in the code are wrong
-
An operation is applied to data of the wrong type
-
Referring to a variable that has not been assigned a value
-
None of the mentioned
Question 114
Question
Functions must be defined ___________ they can be called?
Answer
-
After
-
Before
-
Instead
-
With def keyword
Question 115
Question
Which of the following is the use of function in python?
Answer
-
Functions are reusable pieces of programs
-
Functions don’t provide better modularity for your application
-
you can’t also create your own functions
-
All of the mentioned
Question 116
Question
Which keyword is use for function?
Question 117
Question
What is the output of the below program ?
Question 118
Question
What is the output of the below program ?
Answer
-
3
-
4
-
4 is maximum
-
3 is maximum
Question 119
Question
What is the output of the below program ?
Answer
-
x is 50 Changed global x to 2 Value of x is 50
-
x is 50 Changed global x to 2 Value of x is 2
-
x is 50 Changed global x to 50 Value of x is 50
-
x is 50 Changed global x to 50 Value of x is 2
Question 120
Question
Which are the advantages of functions in python?
Answer
-
Reducing duplication of code
-
Decomposing complex problems into simpler pieces
-
Improving clarity of the code
-
All of the mentioned
Question 121
Question
What are the two types of functions?
Answer
-
Custom function and Built-in function
-
Built-in function and User-Defined function
-
Custom function and System function
-
System function and User-Defined function
Question 122
Question
Where is function defined?
Answer
-
Module
-
Class
-
Another function
-
All of the mentioned
Question 123
Question
What is the output of below program ?
Question 124
Question
What is the output of below program ?
Question 125
Question
What are the keys? for d = {"john":40, "peter":45}
Answer
-
“john”, 40, 45, and “peter”
-
“john” and “peter”
-
40 and 45
-
d = (40:”john”, 45:”peter”)
Question 126
Question
What will be the output ?
Question 127
Question
What will be the output ?
Question 128
Question
What will be the output
Question 129
Question
What is the output for code? >> d = {"john":40, "peter":45} >> d["john"]
Question 130
Question
Suppose d = {“john”:40, “peter”:45}, what happens when retieving a value using d[“susan”]?
Answer
-
Since “susan” is not a value in the set, Python raises a KeyError exception.
-
It is executed fine and no exception is raised, and it returns None.
-
Since “susan” is not a key in the set, Python raises a KeyError exception.
-
Since “susan” is not a key in the set, Python raises a syntax error.
Question 131
Question
Choose the correct expressing computations definition for “Display data on the screen or send data to a file or other device”
Answer
-
Input
-
Output
-
Maths
-
Repetition
Question 132
Question
Choose the correct expressing computations definition for “Perform basic mathematical operations like addition and multiplication”
Answer
-
Input
-
Output
-
Maths
-
Repetition
Question 133
Question
Choose the correct expressing computations definition for “Check for certain conditions and execute the appropriate code”
Answer
-
Input
-
Output
-
Conditional logic
-
Repetition
Question 134
Question
Choose the correct expressing computations definition for “Perform some action repeatedly, usually with some variation”
Answer
-
Input
-
Output
-
Maths
-
Repetition
Question 135
Question
Choose the correct definition for High level code
Answer
-
Syntax a specific type of computer can understand
-
Also known as Assembly or Machine Code
-
Rare to directly create now
-
Human friendly syntax
Question 136
Question
_________________is a name that refers to a value
Answer
-
Variable
-
Name
-
Value
-
Nothing
Question 137
Question
_______________________is used to create variables and to give them values
Answer
-
Assignment statement
-
Variable
-
Naming
-
Statement
Question 138
Question
We can use the ______________ function to check the type of a variable
Answer
-
Type()
-
Check()
-
Variable()
-
Str()
Question 139
Question
We can alter the type of a variable using the following functions, which is “converts variable to a string”
Answer
-
Type()
-
Int()
-
Float()
-
Str()
Question 140
Question
We can alter the type of a variable using the following functions, which is “converts variable to a integer”
Answer
-
Type()
-
Int()
-
Float()
-
Str()
Question 141
Question
We can alter the type of a variable using the following functions, which is “converts variable to a float”
Answer
-
Type()
-
Int()
-
Float()
-
Str()
Question 142
Question
Choose the keyword that cannot be used as names for variables as they already have a meaning and purpose.
Answer
-
def
-
definition
-
purpose
-
printing
Question 143
Question
Lists are a commonly used, simple compound data type in Python, choose the correct answer for “index starts at 0”
Answer
-
mylist[0]
-
mylist[-1]
-
mylist[2:4]
-
mylist[1]
Question 144
Question
Lists are a commonly used, simple compound data type in Python, choose the correct answer for “reversing from the last value”
Answer
-
mylist[0]
-
mylist[-1]
-
mylist[2:4]
-
mylist[1]
Question 145
Question
Lists are a commonly used, simple compound data type in Python, choose the correct answer for “subset of the values”
Answer
-
mylist[0]
-
mylist[-1]
-
mylist[2:4]
-
mylist[1]
Question 146
Question
in python we use data type, that has keys with values called?
Answer
-
Lists
-
Dictionaries
-
Dairies
-
Compounds
Question 147
Question
There is dictionary called telnumbers = {‘john’: 756, ‘mike’: 789, ‘alex’: 456, ‘sue’: 123}, how to print everything from the dictionary?
Answer
-
print numbers
-
telnumbers
-
telnumbers[‘alex’]
-
telnumbers.keys()
Question 148
Question
There is dictionary called telnumbers = {‘john’: 756, ‘mike’: 789, ‘alex’: 456, ‘sue’: 123}, how to print dictionary keys?
Answer
-
print numbers
-
telnumbers
-
telnumbers[‘alex’]
-
telnumbers.keys()
Question 149
Question
There is dictionary called telnumbers = {‘john’: 756, ‘mike’: 789, ‘alex’: 456, ‘sue’: 123}, how to print Alex’s telephone number?
Answer
-
print numbers[‘alex’]
-
telnumbers
-
telnumbers[‘alex’]
-
telnumbers.keys()
Question 150
Question
There is dictionary called telnumbers = {‘john’: 756, ‘mike’: 789, ‘alex’: 456, ‘sue’: 123}, which of the following is the dictionary key?
Answer
-
‘john’
-
756
-
‘alua’
-
numbers.keys
Question 151
Question
There is dictionary called telnumbers = {‘john’: 756, ‘mike’: 789, ‘alex’: 456, ‘sue’: 123}, which of the following is the dictionary value?
Answer
-
‘john’
-
756
-
‘456’
-
numbers.keys
Question 152
Question
choose the correct definition for ‘syntax error’
Answer
-
The structure or tokens in the code are wrong
-
An operation is applied to data of the wrong type
-
Referring to a variable that has not been assigned a value
-
None of the mentioned
Question 153
Question
choose the correct definition for ‘type error’
Answer
-
The structure or tokens in the code are wrong
-
An operation is applied to data of the wrong type
-
Referring to a variable that has not been assigned a value
-
None of the mentioned
Question 154
Question
choose the correct definition for ‘name error’
Answer
-
The structure or tokens in the code are wrong
-
An operation is applied to data of the wrong type
-
Referring to a variable that has not been assigned a value
-
None of the mentioned
Question 155
Question
Functions must be defined ___________ they can be called?
Answer
-
After
-
Before
-
Instead
-
With def keyword
Question 156
Question
Which of the following is the use of function in python?
Answer
-
Functions are reusable pieces of programs
-
Functions don’t provide better modularity for your application
-
you can’t also create your own functions
-
All of the mentioned
Question 157
Question
Which keyword is use for function?
Question 158
Question
What is the output of the below program ?
Question 159
Question
What is the output of the below program ?
Answer
-
3
-
4
-
4 is maximum
-
3 is maximum
Question 160
Question
What is the output of the below program ?
Answer
-
x is 50 Changed global x to 2 Value of x is 50
-
x is 50 Changed global x to 2 Value of x is 2
-
x is 50 Changed global x to 50 Value of x is 50
-
x is 50 Changed global x to 50 Value of x is 2
Question 161
Question
Which are the advantages of functions in python?
Answer
-
Reducing duplication of code
-
Decomposing complex problems into simpler pieces
-
Improving clarity of the code
-
All of the mentioned
Question 162
Question
What are the two types of functions?
Answer
-
Custom function and Built-in function
-
Built-in function and User-Defined function
-
Custom function and System function
-
System function and User-Defined function
Question 163
Question
Where is function defined?
Answer
-
Module
-
Class
-
Another function
-
All of the mentioned
Question 164
Question
What is the output of below program ?
Question 165
Question
What is the output of below program ?
Question 166
Question
What are the keys? for d = {"john":40, "peter":45}
Answer
-
“john”, 40, 45, and “peter”
-
“john” and “peter”
-
40 and 45
-
d = (40:”john”, 45:”peter”)
Question 167
Question
What will be the output ?
Question 168
Question
What will be the output ?
Question 169
Question
What will be the output ?
Question 170
Question
What is the output for code? >> d = {"john":40, "peter":45} >> d["john"]
Question 171
Question
Suppose d = {“john”:40, “peter”:45}, what happens when retieving a value using d[“susan”]?
Answer
-
Since “susan” is not a value in the set, Python raises a KeyError exception.
-
It is executed fine and no exception is raised, and it returns None.
-
Since “susan” is not a key in the set, Python raises a KeyError exception.
-
Since “susan” is not a key in the set, Python raises a syntax error.
Question 172
Question
What is the output of the below program ?
Answer
-
x is 50 Changed global x to 2 Value of x is 50
-
x is 50 Changed global x to 2 Value of x is 2
-
x is 50 Changed global x to 50 Value of x is 50
-
x is 50 Changed global x to 50 Value of x is 2
Question 173
Question
Which are the advantages of functions in python?
Answer
-
Reducing duplication of code
-
Decomposing complex problems into simpler pieces
-
Improving clarity of the code
-
All of the mentioned
Question 174
Question
What are the two types of functions?
Answer
-
Custom function and Built-in function
-
Built-in function and User-Defined function
-
Custom function and System function
-
System function and User-Defined function
Question 175
Question
Where is function defined?
Answer
-
Module
-
Class
-
Another function
-
All of the mentioned
Question 176
Question
What is the output of below program ?
Question 177
Question
What is the output of below program ?
Question 178
Question
What are the keys? for d = {"john":40, "peter":45}
Answer
-
“john”, 40, 45, and “peter”
-
“john” and “peter”
-
40 and 45
-
d = (40:”john”, 45:”peter”)
Question 179
Question
What will be the output ?
Question 180
Question
What will be the output ?