Def abc val y y append val

Explanation: The maximum possible length of an identifier is not defined in the python language. It can be of any number.


2) Who developed the Python language?

  1. Zim Den
  2. Guido van Rossum
  3. Niene Stom
  4. Wick van Rossum
Show Answer Workspace

Answer: (b) Guido van Rossum

Explanation: Python language was developed by Guido van Rossum in the Netherlands.


3) In which year was the Python language developed?

Show Answer Workspace

Answer: (d) 1989

Explanation: Python language was developed by Guido van Rossum in 1989.


4) In which language is Python written?

  1. English
  2. PHP
  3. C
  4. All of the above
Show Answer Workspace

Answer: (b) C

Explanation: Python is written in C programming language, and it is also called CPython.


5) Which one of the following is the correct extension of the Python file?

  1. .py
  2. .python
  3. .p
  4. None of these
Show Answer Workspace

Answer: (a) .py

Explanation: ".py" is the correct extension of the Python file.


6) In which year was the Python 3.0 version developed?

Show Answer Workspace

Answer: (a) 2008

Explanation: Python 3.0 version was developed on December 3, 2008.


7) What do we use to define a block of code in Python language?

  1. Key
  2. Brackets
  3. Indentation
  4. None of these
Show Answer Workspace

Answer: (c) Indentation

Explanation: Python uses indentation to define blocks of code. Indentations are simply spaces or tabs used as an indicator that is part of the indent code child. As used in curly braces C, C++, and Java.


8) Which character is used in Python to make a single line comment?

Show Answer Workspace

Answer: (c) #

Explanation: "#" character is used in Python to make a single-line comment.


9) Which of the following statements is correct regarding the object-oriented programming concept in Python?

  1. Classes are real-world entities while objects are not real
  2. Objects are real-world entities while classes are not real
  3. Both objects and classes are real-world entities
  4. All of the above
Show Answer Workspace

Answer: (b) Objects are real-world entities while classes are not real

Explanation: None


10) Which of the following statements is correct in this python code?

  1. It will throw the error as multiple references to the same object is not possible
  2. id(name1) and id(name2) will have same value
  3. Both name1 and name2 will have reference to two different objects of class Name
  4. All of the above
Show Answer Workspace

Answer: (b) id(name1) and id(name2) will have same value

Explanation: "name1" and "name2" refer to the same object, so id(name1) and id(name2) will have the same value.


11) What is the method inside the class in python language?

  1. Object
  2. Function
  3. Attribute
  4. Argument
Show Answer Workspace

Answer: (b) Function

Explanation: Function is also known as the method.


12) Which of the following declarations is incorrect?

  1. _x = 2
  2. __x = 3
  3. __xyz__ = 5
  4. None of these
Show Answer Workspace

Answer: (d) None of these

Explanation: All declarations will execute successfully but at the expense of low readability.


13) Why does the name of local variables start with an underscore discouraged?

  1. To identify the variable
  2. It confuses the interpreter
  3. It indicates a private variable of a class
  4. None of these
Show Answer Workspace

Answer: (c) It indicates a private variable of a class

Explanation: Since there is no concept of private variables in Python language, the major underscore is used to denote variables that cannot be accessed from outside the class.


14) Which of the following is not a keyword in Python language?

Show Answer Workspace

Answer: (a) val

Explanation: "val" is not a keyword in python language.


15) Which of the following statements is correct for variable names in Python language?

  1. All variable names must begin with an underscore.
  2. Unlimited length
  3. The variable name length is a maximum of 2.
  4. All of the above
Show Answer Workspace

Answer: (b) Unlimited length

Explanation: None


16) Which of the following declarations is incorrect in python language?

  1. xyzp = 5,000,000
  2. x y z p = 5000 6000 7000 8000
  3. x,y,z,p = 5000, 6000, 7000, 8000
  4. x_y_z_p = 5,000,000
Show Answer Workspace

Answer: (b) x y z p = 5000 6000 7000 8000

Explanation: Spaces are not allowed in variable names.


17) Which of the following words cannot be a variable in python language?

Show Answer Workspace

Answer: (c) try

Explanation: "try" is a keyword.


18) Which of the following operators is the correct option for power(ab)?

Show Answer Workspace

Answer: (b) a**b

Explanation: The power operator in python is a**b, i.e., 2**3=8.


19) Which of the following precedence order is correct in Python?

  1. Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
  2. Multiplication, Division, Addition, Subtraction, Parentheses, Exponential
  3. Division, Multiplication, Addition, Subtraction, Parentheses, Exponential
  4. Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
Show Answer Workspace

Answer: (a) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction

Explanation: PEMDAS (similar to BODMAS).


20) Which one of the following has the same precedence level?

  1. Division, Power, Multiplication, Addition and Subtraction
  2. Division and Multiplication
  3. Subtraction and Division
  4. Power and Division
Show Answer Workspace

Answer: (b) Division and Multiplication

Explanation: None


21) Which one of the following has the highest precedence in the expression?

  1. Division
  2. Subtraction
  3. Power
  4. Parentheses
Show Answer Workspace

Answer: (d) Parentheses

Explanation: PEMDAS (similar to BODMAS).


22) Which of the following functions is a built-in function in python language?

  1. val()
  2. print()
  3. print()
  4. None of these
Show Answer Workspace

Answer: (b) print()

Explanation: The print() function is a built-in function in python language that prints a value directly to the system.


23) Study the following function:

What will be the output of this function?

Show Answer Workspace

Answer: (d) 5

Explanation: The round function is a built-in function in the Python language that round-off the value (like 3.85 is 4), so the output of this function will be 5.


24) Which of the following is correctly evaluated for this function?

  1. (x**y) / z
  2. (x / y) * z
  3. (x**y) % z
  4. (x / y) / z
Show Answer Workspace

Answer: (c) (x**y) % z

Explanation: None


25) Study the following function:

What will be the output of this function?

Show Answer Workspace

Answer: (a) False

Explanation: If any element is zero, it returns a false value, and if all elements are non-zero, it returns a true value. Hence, the output of this "all([2,4,0,6])" function will be false.


26) Study the following program:

What will be the output of this code?

  1. error
  2. 2 1
  3. 0 3 1
  4. None of these
Show Answer Workspace

Answer: (a) error

Explanation: Syntax error, there should not be a space between + and =.


27) Which one of the following syntaxes is the correct syntax to read from a simple text file stored in ''d:\java.txt''?

  1. Infile = open(''d:\\java.txt'', ''r'')
  2. Infile = open(file=''d:\\\java.txt'', ''r'')
  3. Infile = open(''d:\java.txt'',''r'')
  4. Infile = open.file(''d:\\java.txt'',''r'')
Show Answer Workspace

Answer: (a) Infile = open(''c:\\scores.txt'', ''r'')

Explanation: None


28) Study the following code:

What will be the output of this program?

  1. ['XX', 'YY']
  2. ['xx', 'yy']
  3. [XX, yy]
  4. None of these
Show Answer Workspace

Answer: (a) ['XX', 'YY']

Explanation: None


29) Study the following function:

What will be the output of this code?

Show Answer Workspace

Answer: (d) 6.0

Explanation: This function prints the square of the value.


30) Study the following function:

What will be the output of this code?

  1. False
  2. Ture
  3. Invalid code
  4. None of these
Show Answer Workspace

Answer: (b) True

Explanation: None


31) Study the following statement:

What will be the output of this statement?

Show Answer Workspace

Answer: (b) abc

Explanation: In Python, the "+" operator acts as a concatenation operator between two strings.


32) Study the following code:

What will be the output of this code?

  1. javatpoint
  2. java
  3. point
  4. None of these
Show Answer Workspace

Answer: (c) point

Explanation: Slice operation is performed on the string.


33) The output to execute string.ascii_letters can also be obtained from:?

  1. character
  2. ascii_lowercase_string.digits
  3. lowercase_string.upercase
  4. ascii_lowercase+string.ascii_upercase
Show Answer Workspace

Answer: (d) string.ascii_lowercase+string.ascii_upercase

Explanation: None


34) Study the following statements:

What will be the output of this statement?

Show Answer Workspace

Answer: (a) t

Explanation: The correct output of this program is "t" because -1 corresponds to the last index.


35) Study the following code:

What will be the output of this statement?

  1. java
    point
  2. java point
  3. \njavat\npoint
  4. Print the letter r and then javat and then point
Show Answer Workspace

Answer: (c) \njavat\npoint

Explanation: None


36) Study the following statements:

What will be the output of this statement?

  1. 33
  2. 63
  3. 0xA + 0xB + 0xC
  4. None of these
Show Answer Workspace

Answer: (a) 33

Explanation: A, B and C are hexadecimal integers with values 10, 11 and 12 respectively, so the sum of A, B and C is 33.


37) Study the following program:

Which of the following is the correct output of this program?

  1. 32
  2. 32 32
  3. 32 None
  4. Error is generated
Show Answer Workspace

Answer: (d) Error is generated

Explanation: Error is generated because self.o1 was never created.


38) Study the following program:

What will be the output of this statement?

  1. Ann Bob
  2. Ann Nick
  3. Wick Bob
  4. Wick Nick
Show Answer Workspace

Answer: (d) Wick Nick

Explanation: None


39) Study the following statements:

What will be the output of this statement?

Show Answer Workspace

Answer: (b) -18

Explanation: ASCII value of h is less than the z. Hence the output of this code is 104-122, which is equal to -18.


40) Study the following program:

Which of the following is correct output of this program?

  1. ['xy', 'yz']
  2. ['XY', 'YZ']
  3. [None, None]
  4. None of these
Show Answer Workspace

Answer: (a) ['xy', 'yz']

Explanation: None


41) Study the following program:

Which of the following is the correct output of this program?

  1. 1 2 3
  2. 3 2 1
  3. 1 2
  4. Invalid syntax
Show Answer Workspace

Answer: (d) Invalid syntax

Explanation: Invalid syntax, because this declaration (i = 1:) is wrong.


42) Study the following program:

Which of the following is correct output of this program?

  1. 1 2 3 4 5
  2. 1 2 3 4 5 6
  3. 1 2 3 4 5 6 7
  4. Invalid syntax
Show Answer Workspace

Answer: (b) 1 2 3 4 5 6

Explanation: None


43) Study the following program:

What will be the output of this statement?

Show Answer Workspace

Answer: (c) 0 1 2

Explanation: None


44) Study the following program:

What will be the output of this statement?

Show Answer Workspace

Answer: (c) 0 1 2 0

Explanation: None


45) Study the following program:

What will be the output of this statement?

  1. xyz
  2. No output
  3. x y z
  4. j j j j j j j..
Show Answer Workspace

Answer: (b) No output

Explanation: "j" is not in "xyz".


46) Study the following program:

Which of the following is the correct output of this program?

Show Answer Workspace

Answer: (b) pqrs

Explanation: None


47) Study the following program:

What will be the output of this statement?

  1. a b c
  2. 0 1 2
  3. 0 a   1 b   2 c
  4. None of these above
Show Answer Workspace

Answer: (b) 0 1 2

Explanation: None


48) Study the following program:

What will be the output of this statement?

  1. {0, 1, 2} {0, 1, 2} {0, 1, 2}
  2. 0 1 2
  3. Syntax_Error
  4. None of these above
Show Answer Workspace

Answer: (b) 0 1 2

Explanation: None


49) Which of the following option is not a core data type in the python language?

  1. Dictionary
  2. Lists
  3. Class
  4. All of the above
Show Answer Workspace

Answer: (c) Class

Explanation: Class is not a core data type because it is a user-defined data type.


50) What error will occur when you execute the following code?

  1. NameError
  2. SyntaxError
  3. TypeError
  4. ValueError
Show Answer Workspace

Answer: (a) NamaError

Explanation: Mango is not defined hence the name error.


51) Study the following program:

What will be the output of this statement?

  1. hello2hello2
  2. hello2
  3. Cannot perform mathematical operation on strings
  4. indentationError
Show Answer Workspace

Answer: (d) indentationError

Explanation: None


52) Which of the following data types is shown below?

What will be the output of this statement?

Show Answer Workspace

Answer: (c) List

Explanation: Any value can be stored in the list data type.


53) What happens when '2' == 2 is executed?

  1. False
  2. Ture
  3. ValueError occurs
  4. TypeError occurs
Show Answer Workspace

Answer: (a) False

Explanation: It only evaluates to false.


54) Study the following program:

What will be the output of this statement?

  1. invalid code
  2. JavaTpoint has not exist
  3. JavaTpoint has exist
  4. none of these above
Show Answer Workspace

Answer: (a) invalid code

Explanation: A new exception class must inherit from a BaseException, and there is no such inheritance here.

Why does Python exist?

It was initially designed by Guido van Rossum in 1991 and developed by Python Software Foundation. It was mainly developed for emphasis on code readability, and its syntax allows programmers to express concepts in fewer lines of code.

Is total a keyword in Python?

Total Python keywords This is a logical operator it returns true if both the operands are true else return false.

What kind of language is Python?

Python is an interpreted, interactive, object-oriented programming language. It incorporates modules, exceptions, dynamic typing, very high level dynamic data types, and classes. It supports multiple programming paradigms beyond object-oriented programming, such as procedural and functional programming.

What are libraries in Python What is the use of libraries in Python?

A Python library is a collection of related modules. It contains bundles of code that can be used repeatedly in different programs. It makes Python Programming simpler and convenient for the programmer. As we don't need to write the same code again and again for different programs.