Programming and Problem Solving Through Python Language Theory Question

Introduction to Python - Set 2

  1. In order to store values, in form of key and value what we use ?
    1. List
    2. Class
    3. Tuple
    4. Dictionary
    Answer : D
    Explain : we use dictionary in which one key define and value store. Example (dictionary name) = { 'key':'value'}
  2. What will be the output of following ?
    print(range(4))
    1. 0,1,2,3
    2. [0,1,2,3]
    3. range(0,4)
    4. Error
    Answer : C
    Explain : In Python, the range() function is used to generate a sequence of numbers within a specified range. The range() function returns an object that represents the sequence of numbers.
  3. The data type whose representation is known are called
    1. Built-in datatype
    2. Derived datatype
    3. Concrete datatype
    4. Abstract datatype
    Answer : C
    Explain : A concrete data type is a data type whose representation is known and relied upon by the programmers who use the data type.If you do not know the representation of a data type and are not allowed to rely upon its representation, then the data type is abstract.
  4. Which of the following is the use of function in python?
    1. Functions do not provide better modularity for applications
    2. One can’t create our own functions
    3. Functions are reusable pieces of programs
    4. All of the above
    Answer : C
    Explain : When function declare it can be reuse anywhere, anytime.
  5. List, tuple, and range are which type of Data Types ?
    1. Sequence Types
    2. Binary Types
    3. Boolean Types
    4. None of the mentioned above
    Answer : A
    Explain :The sequence Types of Data Types are the list, the tuple, and the range. In order to store multiple values in an organized and efficient manner, we use the concept of sequences
  6. Which function is used to get the version of python?
    1. system.getversion
    2. sys.version(1)
    3. system.get
    4. None of the above
    Answer : B
    Explain : sys.version(1) is used to known about python version.
  7. Which function is used to get ASCII value of any character in python ?
    1. as()
    2. ascii()
    3. bin()
    4. ord()
    Answer : D
    Explain : ord () is used to check ascii value and bin() is used to get binary value.
  8. Python is a which type of programming language ?
    1. High level
    2. Low level
    3. Object oriented
    4. Both a and c
    Answer : D
    Explain : Python is high level, scripted language and object oriented language.
  9. What is the full form of IDLE in python ?
    1. Integrated Development and Learning Environment
    2. Interpreter Development and Learning Environment
    3. Integrated Developed and Learning Environment
    4. Integer Development and Learning Environment
    Answer : A
    Explain : IDLE (short for Integrated Development and Learning Environment) is an integrated development environment for Python.
  10. The command used to start python from the command prompt is ?
    1. execute python
    2. python
    3. py
    4. Both B and C
    Answer : D
    Explain : We can use both python and py on cmd to run python.
  11. Python Literals is used to define the data that is given in a variable or constant?
    1. True
    2. False
    Answer : A
    Explain : Literals in Python used as data that is provided in a variable or constant. Literal collections are supported in Python as well as String and Numeric literals, Boolean and Boolean expressions, Special literals, and Special expressions.
  12. Which escape sequence represents the new line in python ?
    1. \n
    2. \'
    3. \"
    4. \r
    Answer : A
    Explain : \n escape seq. is used to add text in newline.
  13. Which function is used to take input from user ?
    1. in()
    2. input()
    3. user()
    4. None
    Answer : B
    Explain : To take input from user, we use input() and int(input()) for integer value.
  14. Which of following is not numeric data types ?
    1. integer
    2. float
    3. complex
    4. list
    Answer : D
    Explain : List is a ordered collection of data. There are three distinct numeric types: integers, floating point numbers, and complex numbers.
  15. Print() function is used for ?
    1. to get output
    2. to take input
    3. to assign value
    4. None of the above
    Answer : A
    Explain : print() function is used to get output in python.

Next Set

1 3 4