0% found this document useful (0 votes)
43 views2 pages

Python Programming MCQs and Answers

Uploaded by

Vidhya Gopinath
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views2 pages

Python Programming MCQs and Answers

Uploaded by

Vidhya Gopinath
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Year/Sem : I / I

Subject : Python programming


1. Who developed Python Programming Language?
a) Wick van Rossum
b) Rasmus Lerdorf
c) Guido van Rossum
d) Niene Stom
Answer: c
2. Which type of Programming does Python support?
a) object-oriented programming
b) structured programming
c) functional programming
d) all of the mentioned
Answer: d
3. Is Python case sensitive when dealing with identifiers?
a) no
b) yes
c) machine dependent
d) none of the mentioned
Answer: b
4. Which of the following is the correct extension of the Python file?
a) .python
b) .pl
c) .py
d) .p
Answer: c
5. Is Python code compiled or interpreted?
a) Python code is both compiled and interpreted
b) Python code is neither compiled nor interpreted
c) Python code is only compiled
d) Python code is only interpreted
Answer: a
6. All keywords in Python are in _________
a) Capitalized
b) lower case
c) UPPER CASE
d) None of the mentioned
Answer: d
7. What will be the value of the following Python expression?
4+3%5
a) 7
b) 2
c) 4
d) 1
Answer: a
8. Which of the following is used to define a block of code in Python language?
a) Indentation
b) Key
c) Brackets
d) All of the mentioned
Answer: a
9. Which keyword is used for function in Python language?
a) Function
b) def
c) Fun
d) Define
Answer: b
10. Which of the following character is used to give single-line comments in Python?
a) //
b) #
c) !
d) /*
Answer: b

Common questions

Powered by AI

The 'def' keyword in Python effectively conveys the intent to define a function, facilitating clear and concise code structure . Its use positively impacts scope management by clearly delineating function blocks, promoting modular programming practices, and improving readability and maintenance.

Python's keywords, being distinct and minimalistic, contribute to its self-documenting nature, improving code readability and comprehension . However, since keywords are case-sensitive and non-uniform in style, this might pose challenges in environments where conventions differ or when integrating with SQL or other case-insensitive systems.

The '.py' file extension signifies Python source files, making it easier to identify Python scripts in a multi-language project environment and facilitating integration with IDEs and version control systems . However, the limitation is that reliance on file extensions for organization may be inadequate for projects with complex directory structures or multiple languages.

In Python, arithmetic operations follow specific precedence rules similar to standard mathematics; addition and modulo are ranked differently, affecting execution order. For '4 + 3 % 5', modulo is performed before addition, resulting in a value of 7 . Understanding precedence is crucial to predict and control calculation outcomes effectively.

Python supports multiple programming paradigms such as object-oriented programming, structured programming, and functional programming, which allow developers to choose the best approach for solving various problems . This versatility in functionality makes Python adaptable to different project needs, enhancing its capability to address broad categories of computational tasks.

Python is case sensitive, meaning that identifiers like 'Variable' and 'variable' would be considered distinct . This requires programmers to maintain consistency in naming conventions, reducing errors but necessitating careful attention to detail in variable and function names.

Python's support for object-oriented programming allows developers to represent real-world concepts as objects, reusing and managing code more efficiently . This supports the development of complex software projects by encouraging modular code and facilitating maintenance and scalability.

Python code is both compiled and interpreted, which means that source code is first compiled into bytecode, which is then interpreted by the Python virtual machine . This process allows Python to be platform-independent while also enabling dynamic execution, fostering an efficient testing and debugging environment.

Python uses indentation to define blocks of code, which enforces uniform code structure and improves readability . While this prevents certain syntax errors found in languages that employ braces or keywords, it also requires stringent control over indentation, as incorrect spacing can lead to logic errors.

Using '#' for single-line comments in Python allows programmers to add inline documentation easily, enhancing code readability and making it more understandable for developers and reviewers . This practice aids in maintaining and updating the code as the intent behind code blocks is clearly documented.

You might also like