Wednesday, 29 July 2020

PYTHON GTU MCQ (CH-1 Python variables and datatypes)

PYTHON 
[SUBJECT CODE: 2180711]
CH-1 PYTHON INTRODUCTION 


Topics Covers:-

  • The basic elements of python 
  • Branching Programs 
  • Control Structures 
  • Strings and Input 
  • Iteration
  • Strings, Tuples, Lists and Dictionaries 
  • Lists and Mutability 
  • Functions as Objects
MCQ:-

1. What is the maximum possible length of an identifier?

a) 31 characters
b) 63 characters
c) 79 characters
d) none of the mentioned

2.Which of the following is invalid?
a) _a = 1
b) __a = 1
c) __str__ = 1
d) none of the mentioned

3.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

4.All keywords in Python are in _________
a) lower case
b) UPPER CASE
c) Capitalized
d) None of the mentioned

5.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

6.Which of the following cannot be a variable?
a) __init__
b) in
c) it
d) on

7.Which of the following is not a keyword?
a) eval
b) assert
c) non local
d) pass

 8.Which one of these is floor division?
a) /
b) //
c) %
d) None of the mentioned

9.Which is the correct operator for power(xy)?
a) X^y
b) X**y
c) X^^y
d) None of the mentioned

10.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

11.Mathematical operations can be performed on a string.
a) True
b) False

12.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

13.What is the output of this expression, 3*1**3?
a) 27
b) 9
c) 3
d) 1

14.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

 15.Which one of the following has the highest precedence in the expression?
a) Exponential
b) Addition
c) Multiplication
d) Parentheses

16.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

17.What will be the output of the following Python code?

  1. >>>str="hello"

  2. >>>str[:2]

  3. >>>

a)he
b)lo
c)olleh
d) hello

18.What is the return type of function id?
a) int
b) float
c) bool
d) dict

19.In python we do not specify types, it is directly interpreted by the compiler, so consider the following operation to be performed.

  1. >>>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

20.What error occurs when you execute the following Python code snippet?

apple = mango

a)SyntaxError
b)NameError
c)ValueError
d)TypeError

21.What will be the output of the following Python code snippet?
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

22.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

23.What is the return value of trunc()?
a) int
b) bool
c) float
d) None

24.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

25.What is the type of inf?
a) Boolean
b) Integer
c) Float
d) Complex


More MCQ Uploading Soon... Stay Tune

Comment Your View In Below Section..
it's Very Helpful...

0 Comments:

Post a Comment