Вы находитесь на странице: 1из 8

Find the word which best describe Python

A. Interpreted
B. Reliable
C. Simple
D. All of these
ANSWER: D

Python identifiers are


A. Case sensitive
B. Case insensitive
C. Machine dependent
D. None of these
ANSWER: A

Find out the invalid variable from the following


A. A_1
B. 1_A
C. _
D. Xyz
ANSWER: B

All keywords in Python are in


A. Lower case
B. UPPER CASE
C. Capitalized
D. None of the above
ANSWER: D

Find out the invalid statement from the following


A. Abc=100
B. A b c=10 20 30
C. A,b,c=10,-40,30
D. A_b_c=50
ANSWER: B

Which line of code produces an error


A. "one" + "2"
B. '5'+6
C. 3+5
D. "5" + "Seven"
ANSWER: B

The input() function takes user’s input as a


A. Integer
B. Float
C. String
D. Character
ANSWER: C

What is the output of this expression: 3*1**3


A. 27
B. 9
C. 3
D. 1
ANSWER: C

Specify the output of print(0.3+0.5==0.8)


A. True
B. False
C. Machine dependent
D. Error
ANSWER: A

The value of the expression float(22//3+3/3) will be


A. 8
B. 8.0
C. 8.3
D. 8.33
ANSWER: B

Which part of if statement should be indented


A. The first statement
B. All the statements
C. Statements within the if block
D. None of these
ANSWER: C

Which statement ends current iteration of loop and continues with the next one
A. Break
B. Continue
C. Skip
D. Pass
ANSWER: B

The output of the statement "for i in range(2.0): print(i)" will be


A. 0 1
B. 0 2
C. Error
D. None of these
ANSWER: C

Which statement is used to terminate the execution of the nearest enclosing loop in
which it appears
A. Pass
B. Break
C. Continue
D. Jump
ANSWER: B

What would happen if we replace the 'break' statement in the code with a 'continue'
A. It will stop executing
B. It would run forever
C. Error
D. There would be no change
ANSWER: B

Which keyword is used to define methods in Python


A. function
B. def
C. method
D. All of these
ANSWER: B

Which predefined Python function is used to find length of string


A. length()
B. len()
C. strlen()
D. stringlength()
ANSWER: B

If a='cpp', b='buzz' then which of the following operation would show 'cppbuzz' as
output
A. a+b
B. a+''+b
C. a+""+b
D. All of the above
ANSWER: D

If a='cpp', b='buzz' then what is the output of: c = a-b print(c)


A. cpp-buzz
B. cppbuzz
C. TypeError: unsupported operand
D. None of the above
ANSWER: C

Find out output of the following code: str="CPPBUZZ" str[:3]


A. UZZ
B. CPP
C. BUZZ
D. CPPB
ANSWER: B

What is the data type of X in X = [12.12, 13, 'cppbuzz']


A. Tuple
B. Array
C. Dictionary
D. List
ANSWER: D

The answer of this expression: 22//3 is


A. 7
B. 1
C. 7.3333
D. 5
ANSWER: A

Maximum possible length of an identifier is


A. 31 characters
B. 63 characters
C. 80 characters
D. None of the above
ANSWER: D

The output of which of the codes shown below will be: 'There are 4 blue birds'
A. 'There are %d %s birds' %(4, "blue")
B. 'There are %s %d birds' %[4, "blue"]
C. 'There are %d %s birds' 4, "blue"
D. 'There are %d %s birds' {4, 'blue'}
ANSWER: A

The index of the first character in a string is


A. 0
B. N
C. N-1
D. 1
ANSWER: A
In Python a string is appended to another string by using which operator
A. +
B. *
C. [ ]
D. +=
ANSWER: D

Which operator is used to repeat a string n number of times


A. +
B. *
C. [ ]
D. +=
ANSWER: B

When using find(), if the string to be searched is not present in the string then
what is returned
A. 0
B. -1
C. N-1
D. ValueError
ANSWER: B

In the split(), if no delimiter is specified, then by default it splits strings on


the character
A. Whitespace
B. Comma
C. Newline
D. Colon
ANSWER: A

Which of the following symbols are used for comments in Python


A. //
B. ''
C. /* */
D. #
ANSWER: D

What is called when a function is defined inside a class


A. Module
B. Class
C. Another function
D. Method
ANSWER: D

What arithmetic operator cannot be used with strings


A. +
B. –
C. *
D. All of the above
ANSWER: B

Which statement invokes a function


A. Function definition
B. Function call
C. Function header
D. All of the above
ANSWER: B

The part of the program in which a variable is accessible is called


A. Scope of the variable
B. Lifetime of the variable
C. Data type of the variable
D. Value of the variable
ANSWER: A

Arbitrary arguments have which symbol in the function definition before the
parameter name
A. &
B. #
C. *
D. $
ANSWER: C

Which function is used to read a string


A. input("Enter a string")
B. eval(input("Enter a string"))
C. enter("Enter a string")
D. eval(enter("Enter a string"))
ANSWER: A

In the expression 45/4, the values on the left and right of the / symbol are called
A. Operators
B. Operands
C. Parameters
D. Arguments
ANSWER: B

Which of the following expression results in a value 1


A. 2 % 1
B. 15 % 4
C. 25 % 5
D. 37 % 6
ANSWER: D

The expression 2**3.0 evaluates to


A. 9
B. 8
C. 9.0
D. 8.0
ANSWER: D

What is the result of evaluating 2+2**3/2


A. 4
B. 6
C. 4.0
D. 6.0
ANSWER: D

The function range(5) return a sequence


A. 1,2,3,4,5
B. 0,1,2,3,4,5
C. 1,2,3,4
D. 0,1,2,3,4
ANSWER: D

Which of the following function returns a sequence 0, 1, 2, 3


A. Range(0,4)
B. Range(0,3)
C. All of the above
D. None of the above
ANSWER: A

Which of the following function is valid


A. range(0,3.5)
B. range(10,4,-1)
C. range(2.5,4.5)
D. range(1,2.5,4.5)
ANSWER: B

Which of the following statement is true


A. The Fibonacci series begins with 0 and 1, and each subsequent number is the sum
of the preceding two numbers in the series.
B. The Fibonacci series begins with 1 and 1, and each subsequent number is the sum
of the preceding two numbers in the series.
C. The Fibonacci series begins with 1 and 2, and each subsequent number is the sum
of the preceding two numbers in the series.
D. The Fibonacci series begins with 2 and 3, and each subsequent number is the sum
of the preceding two numbers in the series.
ANSWER: A

Which of the following statement is true


A. Recursive functions run faster than non-recursive functions
B. Recursive functions usually take more memory space than non-recursive functions
ANSWER: B

Which of the following code displays the area of a circle if the radius is positive
A. if radius != 0: print(radius * radius * 3.14159)
B. if radius >= 0: print(radius * radius * 3.14159)
C. if radius > 0: print(radius * radius * 3.14159)
D. if radius <= 0: print(radius * radius * 3.14159)
ANSWER: C

Suppose isPrime is a boolean variable, which of the following is the correct and
best statement for testing if isPrime is true
A. if isPrime = True:
B. if isPrime == True:
C. if isPrime:
D. if not isPrime = False:
ANSWER: C

Given |x – 2| <= 4, Which of the following is true


A. x - 2 <= 4 and x - 2 >= 4
B. x - 2 <= 4 and x - 2 > -4
C. x - 2 <= 4 and x - 2 >= -4
D. x - 2 <= 4 or x - 2 >= -4
ANSWER: C

In Python, a string literal is enclosed in


A. Parentheses
B. Brackets
C. Single-quotes
D. Braces
ANSWER: C

Which of the following statement prints "smith\exam1\test"


A. print("smith\exam1\test")
B. print("smith\\exam1\\test")
C. print("smith\"exam1\"test")
D. print("smith"\exam1"\test")
ANSWER: B

The expression "Good " + 1 + 2 + 3 evaluates to


A. Good123
B. Good6
C. Good 123
D. Illegal expression
ANSWER: D

To format a number x to 3 digits after the decimal point, use


A. format(x, "5.3f")
B. format("5.3f", x)
C. format(x, "5.4f")
D. format("5.3f", x)
ANSWER: A

The header of a function consists of


A. Function name
B. Function name and parameter list
C. Parameter list
D. None of the above
ANSWER: B

A function
A. Must have at least one parameter
B. May have no parameters
C. Must always have a return statement to return a value
D. Must always have a return statement to return multiple values
ANSWER: B

A variable defined inside a function is referred to as


A. Global variable
B. Function variable
C. Block variable
D. Local variable
ANSWER: D

Whenever possible, one should avoid using


A. Global variables
B. Function parameters
C. Global constants
D. Local variables
ANSWER: A

What is the ouput of "Programming"[4:6]


A. ram
B. ra
C. r
D. pr
ANSWER: B

What is the output of "Programming"[-3]


A. Pr
B. P
C. ing
D. i
E. n
ANSWER: D

Given a string s = "Welcome", which of the following code is incorrect


A. print(s[0])
B. print(s.lower())
C. s[1] = 'r'
D. print(s.strip())
ANSWER: C

Given a string s = "Welcome", what is the value of s.count('e')


A. 1
B. 2
C. 3
D. 4
ANSWER: B

Вам также может понравиться