Ticker

6/recent/ticker-posts

Python mcq with explanation for competitive exam preperation level1


Python mcq with explanation for competitive exam preperation  level1


Q1. Which is not python keyword?

(a) for 

(b) is

(c) with

(d) myfile

Explanation (d)

Keywords are predefined words with special meaning to the language compiler or interpreter. for, is, with are keyword but myfile is identifiers are the names given to different parts of the program. 

Q2. which of the is an invalid variable?

(a) my_day_2

(b) 2nd_day

(c) Day_two

(d)_2

Explanation (b)

Variables represent labelled storage locations whose values can be manipulated during program run.

so naming rules for python identifiers variable names cannot begin with a number, although they can contain numbers.

Q3. Which of these is not a core data  type?

(a) List

(b) Dictionary

(c) Tuples

(d) Class

Explanation (d)

core data type of python

numbers, set, None, Sequence(String,Tuple,List) , Mapping(Dictionary)

So class is not core datatype.

Q4. Which value type does input return?

(a) Boolean

(b) String

(c) Int

(d) Float

Explanation (b)

To get the input from users interactively you can use built in function input().

variable_to_hold_value=input(<prompt to be displayed>)

The input() function always return a value of string type.

Q5. Which is valid arithmetic operator in python

(a) //

(b) ?

(c) <

(d) and

Explanation (a)

// flor division is arithmetic operator

 6.0// 3=2

Q6 Empty statement in python

Explanation None

Q7 Token is also called

Explanation Lexical unit

Q8 Data type whose value cannot be changed in placed are called

Explanation Immutable type

Q9. employee=('john', 'ram') what is length of  tuple employee

Explanation len(employee)

                   2 the method returns length of the tuple. The count of elements in the tuple.


Q10  x=(1,2,3) what is maximum value of tuple

Explanation max(x)

                        3

This methods returns the element from the tuple having maximum value.


   

Post a Comment

0 Comments