Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

1 MCQ Class 11th Variables

The document contains multiple-choice questions (MCQs) related to Python variable names, basic operators, core data types, and numeric types. Each section includes questions with options and the correct answers along with explanations. It serves as a study guide for understanding Python programming concepts.

Uploaded by

Palak Soni
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

1 MCQ Class 11th Variables

The document contains multiple-choice questions (MCQs) related to Python variable names, basic operators, core data types, and numeric types. Each section includes questions with options and the correct answers along with explanations. It serves as a study guide for understanding Python programming concepts.

Uploaded by

Palak Soni
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

MCQ PYTHON VARIABLE NAMES By Gajendra Sir Mo. No.

: 9810301034
VARIABLE NAMES
1. Is Python case sensitive when dealing with identifiers?
a) Yes b) no c) Machine dependent d) none of the mentioned
2. What is the maximum possible length of an identifier?
a) 31 characters b) 63 characters c) 79 characters d) none of the mentioned
3. Which of the following is invalid?
a) _a = 1 b) __a = 1 c) __str__ = 1 d) none of the mentioned
4. Which of the following is an invalid variable?
a) my_string_1 b) 1st_string c) foo d) _
5. Why are local variable names beginning with an underscore discouraged?
a) they are used to indicate a private variables of a class b) they confuse the interpreter
c) they are used to indicate global variables d) they slow down execution
6. Which of the following is not a keyword?
a) eval b) assert c) nonlocal d) pass
7. All keywords in Python are in
a) lower case b) UPPER CASE c) Capitalized d) None of the mentioned
8. Which of the following is true for variable names in Python?
a) Unlimited length b) All private members must have leading and trailing underscores
c) Underscore and ampersand are the only two special characters allowed d) None of the mentioned
9. Which of the following is an invalid statement?
a) abc = 1,000,000 b) a b c = 1000 2000 3000 c) a,b,c = 1000, 2000, 3000 d) a_b_c = 1,000,000
10. Which of the following cannot be a variable?
a) __init__ b) in c) it d) on
BASIC OPERATORS
1. Which is the correct operator for power(xy)?
a) X^y b) X**y c) X^^y d) None of the mentioned
2. Which one of these is floor division?
a) / b) // c) % d) None of the mentioned
3. What is the order of precedence in python?
i) Parentheses ii) Exponential iii) Multiplication iv) Division v) Addition vi) Subtraction
a) i,ii,iii,iv,v,vi b) ii,i,iii,iv,v,vi c) ii,i,iv,iii,v,vi d) i,ii,iii,iv,vi,v
4. What is the answer to this expression, 22 % 3 is?: a) 7 b) 1 c) 0 d) 5
5. Mathematical operations can be performed on a string. State whether true or false. a) True b) False
6. Operators with the same precedence are evaluated in which manner?
a) Left to Right b) Right to Left c) Can’t say d) None of the mentioned
7. What is the output of this expression, 3*1**3? : a) 27 b) 9 c) 3 d) 1
8. Which one of the following has the same precedence level?
a) Addition and Subtraction b) Multiplication, Division and Addition
c) Multiplication, Division, Addition and Subtraction d) Addition and Multiplication
9. The expression Int(x) implies that the variable x is converted to integer. State whether true or false.
a) True b) False
10. Which one of the following has the highest precedence in the expression?
a) Exponential b) Addition c) Multiplication d) Parentheses
CORE DATA TYPES
1. Which of these in not a core data type?
a) Lists b) Dictionary c) Tuples d) Class
2. Given a function that does not return any value, What value is thrown by default when executed in shell.
a) int b) bool c) void d) None
3. Following set of commands are executed in shell, what will be the output? str="hello" str[:2]
a) he b) lo c) olleh d) hello
4. Which of the following will run without errors ?
a) round(45.8) b) round(6352.898,2,5) c) round() d) round(7463.123,2,1)

Page 1 of 4 Computer Science 083 PYTHON pgt.csip.gajedra@gmail.com


MCQ PYTHON VARIABLE NAMES By Gajendra Sir Mo. No. : 9810301034
5. What is the return type of function id?: a) int b) float c) bool d) dict
6. 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)
a) x = 13 // 2 b) x = int(13 / 2) c) x = 13 % 2 d) All of the mentioned
7. What error occurs when you execute? apple = mango
a) SyntaxError b) NameError c) ValueError d) TypeError
8. Carefully observe the code and give the answer.
def example(a):
a = a + '2' ; a = a*2 ; return a
example ("hello")
a) Indentation Error b) cannot perform mathematical operation on strings c) hello2 d) hello2hello2
9. What data type is the object below? L = [1, 23, ‘hello’, 1].
a) list b) dictionary c) array d) tuple
10. In order to store values in terms of key and value we use what core data type.
a) list b) tuple c) class d) dictionary
11. Which of the following results in a SyntaxError ?
a) ‘”Once upon a time…”, she said.’ b) “He said, ‘Yes!'” c) ‘3\’ d) ”’That’s okay”’
12. The following is displayed by a print function call:
tom
dick
harry
Select all of the function calls that result in this output
a) print('''tom b) print('''tomdickharry''') dick
\ndick c) print('tom\ndick\nharry') harry')
\nharry''') d) print('tom
13. What is the average value of the code that is executed below ?
grade1 = 80; grade2 = 90; average = (grade1 + grade2) / 2
a) 85.0 b) 85.1 c) 95.0 d) 95.1
14. Select all options that print : hello-how-are-you
a) print(‘hello’, ‘how’, ‘are’, ‘you’) b) print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
c) print(‘hello-‘ + ‘how-are-you’) d) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
15. What is the return value of trunc() ? a) int b) bool c) float d) None
NUMERIC TYPES
1. What is the output of print 0.1 + 0.2 == 0.3?
a) True b) False c) Machine dependent d) Error
2. Which of the following is not a complex number?
a) k = 2 + 3j b) k = complex(2, 3) c) k = 2 + 3l d) k = 2 + 3J
3. What is the type of inf?: a) Boolean b) Integer c) Float d) Complex
4. What does ~4 evaluate to? : a) -5 b) -4 c) -3 d) +3
5. What does ~~~~~~5 evaluate to? : a) +5 b) -11 c) +11 d) -5
6. Which of the following is incorrect?: a) x = 0b101 b) x = 0x4f5 c) x = 19023 d) x = 03964
7. What is the result of max(3, 1)?
a) 1 b) 3 c) True d) False
8. Which of the following is incorrect?
a) float(‘inf’) b) float(‘nan’) c) float(’56’+’78’) d) float(’12+34′)
9. What is the result of round(0.5) – round(-0.5)?
a) 1.0 b) 2.0 c) 0.0 d) None of the mentioned
round(0.5) is 1 and round(-0.5) is -1.
10. What does 3 ^ 4 evaluate to?
a) 81 b) 12 c) 0.75 d) 7

Page 2 of 4 Computer Science 083 PYTHON pgt.csip.gajedra@gmail.com


MCQ PYTHON VARIABLE NAMES By Gajendra Sir Mo. No. : 9810301034
VARIABLE NAMES Reasons
Ans 1. a [ Case is always significant. ]
Ans 2. d [ Identifiers can be of any length. ]
Ans 3. d [ All the statements will execute successfully but at the cost of reduced readability. ]
Ans 4. b [ Variable names should not start with a number ]
Ans 5. a [ As Python has no concept of private variables, leading underscores are used to indicate
variables that must not be accessed from outside the class. ]
Ans 6. a [ eval can be used as a variable.]
Ans 7. d [ True, False and None are capitalized while the others are in lower case. ]
Ans 8. a [ no rule for length of variable. ]
Ans 9. b [ Spaces are not allowed in variable names. ]
Ans 10. b [ in is a keyword. ]

BASIC OPERATORS Reasons


Ans 1. b [ In python, power operator is x**y i.e. 2**3=8. ]
Ans 2. b [ When both of the operands are integer then python chops out the fraction part and gives you the round off
value, to get the accurate answer use floor division. This is floor division. For ex, 5/2 = 2.5 but both of the operands are integer so
answer of this expression in python is 2.To get the 2.5 answer, use floor division. ]
Ans 3. a [ For order of precedence, just remember this PEMDAS (similar to BODMAS) ]
Ans 4. b [ Modulus operator gives the remainder. So, 22%3 gives the remainder, that is, 1. ]
Ans 5. b [ You can’t perform mathematical operation on string even if the string is in the form: ‘1234…’. ]
Ans 6. a [ None. ]
Ans 7. c [ First this expression will solve 1**3 because exponential has higher precedence than multiplication, so 1**3 = 1
and 3*1 = 3. Final answer is 3. ]
Ans 8. a [ “Addition and Subtraction” are at the same precedence level. Similarly, “Multiplication and Division” are at the
same precedence level. However, Multiplication and Division operators are at a higher precedence level than Addition and
Subtraction operators.
Ans 9. a [ None.
Ans 10. d [ Just remember: PEMDAS, that is, Parenthesis, Exponentiation, Division, Multiplication, Addition, Subtraction.
Note that the precedence order of Division and Multiplication is the same. Likewise, the order of Addition and Subtraction is also
the same. ]
CORE DATA TYPES Reasons
Ans 1. d [ Class is a user defined data type. ]
Ans 2. d [ Python shell throws a None Type object back. ]
Ans 3. a [ We are printing only the 1st two bytes of string and hence the answer is “he”. ]
Ans 4. a [ Execute help(round) in the shell to get details of the parameters that are passed into the round function. ]
Ans 5. a [ Execute help(id) to find out details in python shell.id returns a integer value that is unique. ]
Ans 6. d [ // is integer operation in python 3.0 and int(..) is a type cast operator. ]
Ans 7. b [ Mango is not defined hence name error. ]
Ans 8. a [ Python codes have to be indented properly. ]
Ans 9. a [ List data type can store any values within it. ]
Ans 10. d [ Dictionary stores values in terms of keys and values. ]
Ans 11. c [ Carefully look at the colons ]
Ans 12. c [ The \n adds a new line. ]
Ans 13. a [ Cause a decimal value of 0 to appear as output. ]
Ans 14. c [ Execute in the shell. ]
Ans 15. a [ Execute help(math.trunc) to get details. ]
NUMERIC TYPES Reasons
Ans 1. b [ Neither of 0.1, 0.2 and 0.3 can be represented accurately in binary. The round off errors from 0.1 and 0.2
accumulate and hence there is a difference of 5.5511e-17 between (0.1 + 0.2) and 0.3. ]
Ans 2. c [ l (or L) stands for long. ]
Ans 3. c [ Infinity is a special case of floating point numbers. It can be obtained by float(‘inf’). ]
Ans 4. a [ ~x is equivalent to -(x+1). ]

Page 3 of 4 Computer Science 083 PYTHON pgt.csip.gajedra@gmail.com


MCQ PYTHON VARIABLE NAMES By Gajendra Sir Mo. No. : 9810301034
Ans 5. a [ ~x is equivalent to -(x+1). ]
Ans 6. d [ Numbers starting with a 0 are octal numbers but 9 isn’t allowed in octal numbers. ]
Ans 7. a [ max(x, y) returns x if x > y, y if x <y ]
Ans 8. d [ ‘+’ cannot be converted to a float. ]
Ans 9. b [ Python rounds off numbers away from 0 when the number to be rounded off is exactly halfway
through. ]
Ans 10. d [ ^ is the Binary XOR operator. ]

Page 4 of 4 Computer Science 083 PYTHON pgt.csip.gajedra@gmail.com

You might also like