Quiz
Python
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (35)
1which of the following is invalid
- A__str__=1
- Bnone of the mentioned
- C__a=1
- D_a=1
21. Is Python case sensitive when dealing with identifiers?
- Aa) yes
- Bb) no
- Cc) machine dependent
- Dd) none of the mentioned
32. What is the maximum possible length of an identifier?
- Aa) 31 characters
- Bb) 63 characters
- Cd) none of the mentioned
- Dc) 79 characters
44. Which of the following is an invalid variable?
- Aa) my_string_1
- Bb) 1st_string
- Cc) foo
- Dd) _
55. Why are local variable names beginning with an underscore discouraged?
- Aa) they are used to indicate a private variables of a class
- Bb) they confuse the interpreter
- Cc) they are used to indicate global variables
- Dd) they slow down execution
66. Which of the following is not a keyword?
- Aa) eval
- Bb) assert
- Cc) nonlocal
- Dd) pass
77. All keywords in Python are in
- Aa) lower case
- Bb) UPPER CASE
- Cc) Capitalized
- Dd) None of the mentioned
88. Which of the following is true for variable names in Python?
- Aa) unlimited length
- Bb) all private members must have leading and trailing underscores
- Cc) underscore and ampersand are the only two special characters allowed
- Dd) none of the mentioned
99. Which of the following is an invalid statement?
- Aa) abc = 1,000,000
- Bb) a b c = 1000 2000 3000
- Cc) a,b,c = 1000, 2000, 3000
- Dd) a_b_c = 1,000,000
1010. Which of the following cannot be a variable?
- Aa) __init__
- Bb) in
- Cc) it
- Dd) on
111. Which is the correct operator for power(xy)?
- Aa) X^y
- Bb) X**y
- Cc) X^^y
- Dd) None of the mentioned
122. Which one of these is floor division?
- Aa) /
- Bb) //
- Cc) %
- Dd) None of the mentioned
133. What is the order of precedence in python?
i) Parentheses ii) Exponential iii) Multiplication iv) Division v) Addition vi) Subtraction- Aa) i,ii,iii,iv,v,vi
- Bb) ii,i,iii,iv,v,vi
- Cc) ii,i,iv,iii,v,vi
- Dd) i,ii,iii,iv,vi,v
144. What is answer of this expression, 22 % 3 is?
- Aa) 7
- Bb) 1
- Cc) 0
- Dd) 5
155. Mathematical operations can be performed on a string. State whether true or false.
- Aa) True
- Bb) False
166. Operators with the same precedence are evaluated in which manner?
- Aa) Left to Right
- Bb) Right to Left
- Cc) Can’t say
- Dd) None of the mentioned
177. What is the output of this expression, 3*1**3?
- Aa) 27
- Bb) 9
- Cc) 3
- Dd) 1
188. Which one of the following have the same precedence?
- Aa) Addition and Subtraction
- Bb) Multiplication and Division
- Cc) Both Addition and Subtraction AND Multiplication and Division
- Dd) None of the mentioned
199. The expression Int(x) implies that the variable x is converted to integer. State whether true or false.
- Aa) True
- Bb) False
20 Which one of the following have the highest precedence in the expression?
- AExponential
- BAddition
- CMultiplication
- DParentheses
211. Which of these in not a core data type?
- Aa) Lists
- Bb) Dictionary
- Cc) Tuples
- Dd) Class
222. Given a function that does not return any value, What value is thrown by default when executed in shell.
- Aa) int
- Bb) bool
- Cc) void
- Dd) None
233. Following set of commands are executed in shell, what will be the output?
>>>str=”hello”
>>>str[:2]- Aa) he
- Bb) lo
- Cc) olleh
- Dd) hello
244. Which of the following will run without errors ?
- Aa) round(45.8)
- Bb) round(6352.898,2,5)
- Cc) round()
- Dd) round(7463.123,2,1)
255. What is the return type of function id ?
- Aa) int
- Bb) float
- Cc) bool
- Dd) dict
266. In python we do not specify types,it is directly interpreted by the compiler, so consider the following operation to be performed. >>>x = 13 ? 2 objective is to make sure x has a integer value, select all that apply (python 3.xx)
- Aa) x = 13 // 2
- Bb) x = int(13 / 2)
- Cc) x = 13 % 2
- Dd) All of the mentioned
277. What error occurs when you execute? apple = mango
- Aa) SyntaxError
- Bb) NameError
- Cc) ValueError
- Dd) TypeError
288. Carefully observe the code and give the answer.def example(a): a = a + ‘2’ a = a*2 return a>>>example(“hello”)
- Aa) indentation Error
- Bb) cannot perform mathematical operation on strings
- Cc) hello2
- Dd) hello2hello2
299. What data type is the object below ? L = [1, 23, ‘hello’, 1].
- Aa) list
- Bb) dictionary
- Cc) array
- Dd) tuple
3010. In order to store values in terms of key and value we use what core data type.
- Aa) list
- Bb) tuple
- Cc) class
- Dd) dictionary
3111. Which of the following results in a SyntaxError ?
- Aa) ‘”Once upon a time…”, she said.’
- Bb) “He said, ‘Yes!’”
- Cc) ‘3\’
- Dd) ”’That’s okay”’
3212. The following is displayed by a print function call:tomdickharrySelect all of the function calls that result in this output
- Aa) print(”’tom\ndick\nharry”’)
- Bb) print(”’tomdickharry”’)
- Cc) print(‘tom\ndick\nharry’)
- Dd) print(‘tomdickharry’)
3313. What is the average value of the code that is executed below ?
>>>grade1 = 80
>>>grade2 = 90
>>>average = (grade1 + grade2) / 2- Aa) 85.0
- Bb) 85.1
- Cc) 95
- Dd) 95.1
3414. Select all options that printhello-how-are-you
- Aa) print(‘hello’, ‘how’, ‘are’, ‘you’)
- Bb) print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
- Cc) print(‘hello-‘ + ‘how-are-you’)
- Dd) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
3515. What is the return value of trunc() ?
- Aa) int
- Bb) bool
- Cc) float
- Dd) None
Information
- Description
- Quiz on Python, created by No Name on 28/12/2019.
- Author
- No Name
- Language
- English
- Views
- 45
- Rating
- No ratings yet Rate this quiz