Bihar BPSC Computer Science Multiple Choice Questions (2000) Pattern BSCERT and NCERT -Part 4

429. Who developed python programming language?

Guido van rossum

430. Which type of programming does python support?

Obj0ect-oriented programming

Structured programming

Functional programming

431. Is python case sensitive when dealing with identifiers?

Yes

432. Which of the following is the correct extension of the python file?

.py

433. Is python code compiled or interpreted?

Python code is both compiled and interpreted

434. All keywords in python are in _________

None of the mentioned

435. What will be the value of the following python expression?

4 + 3 % 5

7

436. Which of the following is used to define a block of code in python language?

Indentation

437. Which keyword is used for function in python language?

Def\

438. Which of the following character is used to give single-line comments in python?

#

439. Which of the following functions can help us to find the version of python that we are currently working on?

Sys.version

440. Python supports the creation of anonymous functions at runtime, using a construct called __________

Lambda

441. What is the order of precedence in python?

Parentheses, exponential, multiplication, division, addition, subtraction

442. What will be the output of the following python code snippet if x=1?

X<<2

4

443. What does pip stand for python?

Preferred installer program

444. Which of the following is true for variable names in python?

Unlimited length

445. Which of the following functions is a built-in function in python?

Print()

446. Which of the following is the use of id() function in python?

Id returns the identity of the object

447. Which of the following is not a core data type in python programming?

Class

448. Which of these is the definition for packages in python?

A folder of python modules

449. What will be the output of the following python function? Len([“hello”,2, 4, 6])

4

450. What is the order of namespaces in which python looks for an identifier?

Python first searches the local namespace, then the global namespace and finally the built-in namespace

451. What will be the output of the following python statement? >>>”a”+”bc”

Abc

452. Which function is called when the following python program is executed?

F = foo()

Format(f)

__str__()

453. Which one of the following is not a keyword in python language?

Eval

454. Which module in the python standard library parses options received from the command line?

Getopt

455. What arithmetic operators cannot be used with strings in python?

–\

456. What will be the output of the following python code?

Print(“abdef”.capitalize())

Abdef

457. Which of the following statements is used to create an empty set in python?

Set()

458. To add a new element to a list we use which python command?

List1.append(5)

459. What will be the output of the following python code?

*abcde *

460. Which one of the following is the use of function in python?

Functions are reusable pieces of programs

461. What is the maximum possible length of an identifier in python?

79 characters

462. What are the two main types of functions in python?

Built-in function & user defined function

463. Which of the following is a python tuple?

(1, 2, 3)

464. What will be the output of the following python code snippet? Z=set(‘abc$de’)

True

465. What will be the output of the following python expression? Round(4.576)

5

466. Which of the following is a feature of python docstring?

In python all functions should have a docstring

Docstrings can be accessed by the __doc__ attribute on objects

It provides a convenient way of associating documentation with python modules, functions, classes, and methods

467. What will be the output of the following python code?

Print(“hello {0[0]} and {0[1]}”.format((‘foo’, ‘bin’)))

Hello foo and bin

468. What is output of print(math.pow(3, 2))?

9

469. Which of the following is the use of id() function in python?

In python id function returns the identity of the object

470. What will be the output of the following python code?

X = [[0], [1]]

Print((‘ ‘.join(list(map(str, x))),))

(‘[0] [1]’,)

471. The process of pickling in python includes ____________

Conversion of a python object hierarchy into byte stream

472. Which is the correct operator for power(xy)?

X**y

473. Which one of these is floor division?

//

474. What is the answer to this expression, 22 % 3 is?

1

475. Mathematical operations can be performed on a string.

False

476. Operators with the same precedence are evaluated in which manner?

Left to right

477. What is the output of this expression, 3*1**3?

3

478. Which one of the following has the same precedence level?

Addition and subtraction

479. The expression int(x) implies that the variable x is converted to integer.

True

480. Which one of the following has the highest precedence in the expression?

Parentheses

481. Which of the following is true?

A graph may contain many edges and no vertices

482. For a given graph g having v vertices and e edges which is connected and has no cycles, which of the following statements is true?

V = e+1

483. For which of the following combinations of the degrees of vertices would the connected graph be eulerian?

1,2,3

484. A graph with all vertices having equal degree is known as a __________

Regular graph

485. Which of the following ways can be used to represent a graph?

Adjacency list, adjacency matrix as well as incidence matrix

486. Which of these in not a core data type?

Class

487. Given a function that does not return any value, what value is thrown by default when executed in shell.

None

488. Which of the following will run without errors?

Round(45.8)

489. What is the return type of function id?

Int

490. 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)

X = 13 // 2

X = int(13 / 2)

X = 13 % 2

491. What error occurs when you execute the following python code snippet?

Apple = mango

Nameerror

492. What data type is the object below?

L = [1, 23, ‘hello’, 1]

List

493. In order to store values in terms of key and value we use what core data type.

Dictionary

494. Which of the following results in a syntaxerror?

‘3\’

495. What is the return value of trunc()?

Int

496. What is the output of print 0.1 + 0.2 == 0.3?

False

497. Which of the following is not a complex number?

K = 2 + 3l

498. What is the type of inf?

Float

499. What does ~4 evaluate to?

-5

500. What does ~~~~~~5 evaluate to?

5

501. Which of the following is incorrect?

X = 03964

502. What is the result of cmp(3, 1)?

1

503. Which of the following is incorrect?

Float(’12+34′)

504. What is the result of round(0.5) – round(-0.5)?

Value depends on python version

505. What does 3 ^ 4 evaluate to?

7

506. The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same.

True

507. Which of the following operators has its associativity from right to left?

**

508. What will be the value of x in the following python expression?

X = int(43.55+2/2)

44

509. What is the value of the following expression?

2+4.00, 2**4.0

(6.0, 16.0)

510. What is the value of the following expression?

Float(22//3+3/3)

8

511. What will be the output of the following python expression?

Print(4.00/(2.0+2.0))

1

512. What will be the value of x in the following python expression?

X = 2+9*((3*12)-8)/10

27.2

513. Which of the following expressions involves coercion when evaluated in python?

1.7 % 2

514. What will be the output of the following python expression?)

24//6%3, 24//4//2

(1,3)

515. Which among the following list of operators has the highest precedence?

+, -, **, %, /, <<, >>, |

**

516. What will be the value of the following python expression?

Float(4+int(2.39)%2)

4

517. Which of the following expressions is an example of type conversion?

4.0 + float(3)

518. Which of the following expressions results in an error?

Int(’10.8’)

519. What will be the value of the following python expression?

4+2**5//10

7

520. The expression 2**2**3 is evaluates as: (2**2)**3.

False

521. What will be the output of the following python expression?

Bin(29)

‘0b11101’

522. What will be the output of the following python expression?

Int(1011)?

1011

523. To find the decimal value of 1111, that is 15, we can use the function:

Int(‘1111’,2)

524. What will be the output of the following python expression if x=15 and y=12?

X & y

12

525. Which of the following expressions results in an error?

Int(1011,2)

526. Which of the following represents the bitwise xor operator?

^

527. What is the value of the following python expression?

Bin(0x8)

‘0b1000’

528. What will be the output of the following python expression?

0x35 | 0x75

117

529. It is not possible for the two’s complement value to be equal to the original value in any case.

False

530. The one’s complement of 110010101 is:

1101010

531. Bitwise _________ gives 1 if either of the bits is 1 and 0 when both of the bits are

Xor

532. What will be the output of the following python expression?

4^12

8

533. Any odd number on being and-ed with ________ always gives hint: any even number on being and-ed with this value always gives 0.

1

534. What will be the value of the following python expression?

Bin(10-2)+bin(12^4)

0b10000b1000

535. Which of the following expressions can be used to multiply a given number ‘a’ by 4?

A<<2

536. What will be the output of the following python code if a=10 and b =20?

A=10

B=20

A=a^b

B=a^b

A=a^b

Print(a,b)

20 10

537. What is the two’s complement of -44?

11010100

538. What will be the output of the following python expression?

~100?

-101

539. What will be the output of the following python statement?

>>>”a”+”bc”

Abc

540. What will be the output of the following python statement?

>>>”abcd”[2:]

Cd

541. The output of executing string.ascii_letters can also be achieved by:

String.lowercase_string.uppercase

542. What will be the output of the following python code?

>>> str1 = ‘hello’

>>> str2 = ‘,’

>>> str3 = ‘world’

>>> str1[-1:]

O

543. What arithmetic operators cannot be used with strings?

544. What will be the output of the following python code?

>>>print (r”\nhello”)

\nhello

545. What will be the output of the following python statement?

>>>print(‘new’ ‘line’)

Newline

546. What will be the output of the following python statement?

>>> print(‘x\97\x98’)

X\97

547. What will be the output of the following python code?

>>>str1=”helloworld”

>>>str1[::-1]

Dlrowolleh

548. What will be the output of the following python code?

Print(0xa + 0xb + 0xc)

33

549. What will be the output of the following python code?

>>>example = “snow world”

>>>print(“%s” % example[4:7])

Wo

550. What will be the output of the following python code?

>>>example = “snow world”

>>>example[3] = ‘s’

>>>print example

Error

551. What will be the output of the following python code?

>>>max(“what are you”)

Y

552. Given a string example=”hello” what is the output of example.count(‘l’)?

2

553. To concatenate two strings to a third what statements are applicable?

S3 = s1.__add__(s2)

554. Which of the following statement prints hello\example\test.txt?

Print(“hello\\example\\test.txt”)

555. Suppose s is “\t\tworld\n”, what is s.strip()?

World

556. The format function, when applied on a string returns ___________

Str

557. What will be the output of the “hello” +1+2+3?

Error

What will be displayed by print(ord(‘b’) – ord(‘a’))?

1

558. Say s=”hello” what will be the return value of type(s)?

Str

559. What is the default value of encoding in encode()?

Utf-8

560. Which of the following commands will create a list?

List1 = list()

List1 = []

List1 = list([1, 2, 3])

561. What is the output when we execute list(“hello”)?

[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]

562. Suppose listexample is [‘h’,’e’,’l’,’l’,’o’], what is len(listexample)?

5

563. Suppose list1 is [2445,133,12454,123], what is max(list1)?

12454

564. Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)?

1

565. Suppose list1 is [1, 5, 9], what is sum(list1)?

15

566. To shuffle the list(say list1) what function do we use?

Random.shuffle(list1)

567. Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], which of the following is correct syntax for slicing operation?

Print(list1[2:])

Print(list1[:2])

Print(list1[:-2])

568. Suppose list1 is [2, 33, 222, 14, 25], what is list1[-1]?

25

569. Suppose list1 is [2, 33, 222, 14, 25], what is list1[:-1]?

[2, 33, 222, 14]

570. Suppose list1 is [1, 3, 2], what is list1 * 2?

[1, 3, 2, 1, 3, 2]

571. Suppose list1 = [0.5 * x for x in range(0, 4)], list1 is:

[0.0, 0.5, 1.0, 1.5]

572. To add a new element to a list we use which command?

List1.append(5)

573. To insert 5 to the third position in list1, we use which command?

List1.insert(2, 5)

574. To remove string “hello” from list1, we use which command?

List1.remove(“hello”)

575. Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)?

2

576. Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1.count(5)?

2

577. Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.reverse()?

[3, 1, 25, 5, 20, 5, 4, 3]

578. Suppose listexample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listexample.extend([34, 5])?

[3, 4, 5, 20, 5, 25, 1, 3, 34, 5]

579. Suppose listexample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listexample.pop(1)?

[3, 5, 20, 5, 25, 1, 3]

580. Suppose listexample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listexample.pop()?

[3, 4, 5, 20, 5, 25, 1]

581. What will be the output of the following python code?

>>>”welcome to python”.split()

[“welcome”, “to”, “python”]

582. What will be the output of the following python code?

>>>list(“a#b#c#d”.split(‘#’))

[‘a’, ‘b’, ‘c’, ‘d’]

583. To which of the following the “in” operator can be used to check if an item is in it?

Lists

Dictionary

Set

584. How many elements are in m?

M = [[x, y] for x in range(0, 4) for y in range(0, 4)]

16

585. Which of the following is the same as list(map(lambda x: x**-1, [1, 2, 3]))?

[1/x for x in (1, 2, 3)]

586. Which of the following is a python tuple?

(1, 2, 3)

587. Suppose t = (1, 2, 4, 3), which of the following is incorrect?

T[3] = 45

588. What is the data type of (1)?

Integer

589. If a=(1,2,3,4), a[1:-1] is _________

(2,3)

590. What type of data is: a=[(1,1),(2,4),(3,9)]?

List of tuples

591. Tuples can’t be made keys of a dictionary.

False

592. Which of these about a set is not true?

Immutable data type

593. Which of the following is not the correct syntax for creating a set?

Set([[1,2],[3,4]])

594. Which of the following statements is used to create an empty set?

Set()

595. If a={5,6,7,8}, which of the following statements is false?

A[2]=45

596. If a={5,6,7}, what happens when a.add(5) is executed?

A={5,6,7}

597. Which of these about a frozenset is not true?

Mutable data type

598. What is the syntax of the following python code?

>>> a=frozenset(set([5,6,7]))

>>> a

Frozenset({5,6,7})

599. Set members must not be hashable.

False

600. What will be the output of the following python code?

S=set()

Type(s)

<class ‘set’>

601. Set makes use of __________ dictionary makes use of ____________

Keys, key values

602. Which of the following lines of code will result in an error?

S={san}

603. Input order is preserved in sets.

False

604. Which of the following functions cannot be used on heterogeneous sets?

Sum

605. Which of the following functions will return the symmetric difference between two sets, x and y?

X ^ y

606. The ____________ function removes the first element of a set and the last element of a list.

Pop

607. The difference between the functions discard and remove is that:

Remove throws an error if the specified element is not present in the set whereas discard does not throw an error in case of absence of the specified element

608. What will be the output of the following python code, if s1= {1, 2, 3}?

S1.issubset(s1)

True

609. Which of the following statements create a dictionary?

D = {}

D = {“john”:40, “peter”:45}

D = {40:”john”, 45:”peter”}

610. What will be the output of the following python code snippet?

D = {“john”:40, “peter”:45}

“john” and “peter”

611. Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command do we use?

Del d[“john”]

612. Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary which command do we use?

Len(d)

613. Suppose d = {“john”:40, “peter”:45}, what happens when we try to retrieve a value using the expression d[“susan”]?

Since “susan” is not a key in the set, python raises a keyerror exception

614. Which of these about a dictionary is false?

The keys of a dictionary can be accessed using values

615. Which of the following is not a declaration of the dictionary?

{1,”a”,2”b”}

616. Which of the following isn’t true about dictionary keys?

Keys must be integers

617. Which of the statements about dictionary values if false?

Values of a dictionary must be unique

618. What will be the output of the following python code snippet?

>>> a={1:”a”,2:”b”,3:”c”}

>>> del a

Del deletes the entire dictionary

619. If a is a dictionary with some key-value pairs, what does a.popitem() do?

Removes an arbitrary element

620. If b is a dictionary, what does any(b) do?

Returns true if any key of the dictionary is true

621. Which of the following functions is a built-in function in python?

Print()

622. What will be the output of the following python expression?

Round(4.576)

5

623. The function pow(x,y,z) is evaluated as:

(x**y) % z

624. What will be the output of the following python function?

All([2,4,0,6])

False

625. What will be the output of the following python expression?

Round(4.5676,2)?

4.57

626. What will be the output of the following python function?

Any([2>8, 4>2, 1>2])

True

627. What will be the output of the following python function?

Import math

Abs(math.sqrt(25))

5

628. What will be the output of the following python function?

Sum(2,4,6)

Sum([1,2,3])

Error, 6

629. What will be the output of the following python function?

All(3,0,4.2)

Error

630. What will be the output of the following python function?

Min(max(false,-3,-4), 2,7)

False

631. What is the output of the function complex()?

0j

632. The function divmod(a,b), where both ‘a’ and ‘b’ are integers is evaluated as:

(a//b, a%b)

633. The function complex(‘2-3j’) is valid but the function complex(‘2 – 3j’) is invalid.

True

634. Which of the following functions does not necessarily accept only iterables as arguments?

Chr()

635. Which of the following functions accepts only integers as arguments?

Chr()

636. Suppose there is a list such that: l=[2,3,4]. If we want to print this list in reverse order, which of the following methods should be used?

List(reversed(l))

637. Which of the following functions will not result in an error when no arguments are passed to it?

Float()

638. Which of the following functions does not throw an error?

Ord(‘ ‘)

639. Which of the following is the use of function in python?

Functions are reusable pieces of programs

640. Which keyword is used for function?

Def

641. Which of the following is a feature of docstring?

Provide a convenient way of associating documentation with python modules, functions, classes, and methods

All functions should have a docstring

Docstrings can be accessed by the __doc__ attribute on objects

642. Which are the advantages of functions in python?

Reducing duplication of code

Decomposing complex problems into simpler pieces

Improving clarity of the code

643. What are the two main types of functions?

Built-in function & user defined function

644. Where is function defined?

Module

Class

Another function

645. What is called when a function is defined inside a class?

Method

646. Which of the following is the use of id() function in python?

Id returns the identity of the object

647. Which of the following refers to mathematical function?

Sqrt

648. Python supports the creation of anonymous functions at runtime, using a construct called __________

Lambda

649. Does lambda contains return statements?

False

650. Lambda is a statement.

False

651. Lambda contains block of statements.

False

652. What is a variable defined outside a function referred to as?

A global variable

653. What is a variable defined inside a function referred to as?

A local variable

654. If a function doesn’t have a return statement, which of the following does the function return?

None

655. What is the type of each element in sys.argv?

String

656. What is the length of sys.argv?

Number of arguments + 1

657. How are keyword arguments specified in the function heading?

Two stars followed by a valid identifier

658. How many keyword arguments can be passed to a function in a single function call?

Zero or more

659. Which module in the python standard library parses options received from the command line?

Getopt

660. How are variable length arguments specified in the function heading?

One star followed by a valid identifier

Leave a Reply

Your email address will not be published. Required fields are marked *