PYTHON
Python is a high-level, general-purpose programming language. It is widely used for web development, software development, data analysis, artificial intelligence, machine learning and automation.
Python was created by Guido van Rossum and was first released in 1991.
Important Features of Python
- Python is a high-level programming language.
- It is an interpreted language.
- It is an object-oriented programming language.
- Python has a simple and readable syntax.
- It is open-source and freely available.
- Python is portable and can run on different operating systems.
- It is dynamically typed, meaning the data type of a variable is determined at runtime.
- Python supports GUI programming, web development, data science and Artificial Intelligence.
Python File Extension
Python programs are generally saved with the extension:
.py
Example: program.py
Python Interpreter
The Python interpreter executes Python code. Generally, Python executes the code line by line, which makes it easier to identify errors.
Variables
A variable is a name used to store data.
x = 10
name = “John”
Common Python Data Types
- int – Integer numbers
- float – Decimal numbers
- str – Text/string
- list – Ordered and changeable collection
- tuple – Ordered and unchangeable collection
- set – Unordered collection of unique values
- dict – Collection of key-value pairs
- bool – True or False
Comments in Python
A single-line comment begins with the hash symbol (#).
# This is a comment
Common Python Functions
- print() – Displays output
- input() – Takes input from the user
- len() – Returns the length of an object
- type() – Returns the data type of an object
Practice Question
1. Who developed the Python programming language?
(A) Dennis Ritchie
(B) Guido van Rossum
(C) James Gosling
(D) Bjarne Stroustrup
Answer: (B) Guido van Rossum
2. Python was first released in which year?
(A) 1985
(B) 1989
(C) 1991
(D) 1995
Answer: (C) 1991
3. Python is a:
(A) Low-level language
(B) High-level programming language
(C) Machine language
(D) Assembly language
Answer: (B) High-level programming language
4. What is the common file extension of a Python program?
(A) .python
(B) .pt
(C) .py
(D) .p
Answer: (C) .py
5. Python is generally considered a/an:
(A) Compiled language only
(B) Interpreted language
(C) Machine language
(D) Assembly language
Answer: (B) Interpreted language
6. Which symbol is used to write a single-line comment in Python?
(A) //
(B) /* */
(C) #
(D) —
Answer: (C) #
7. Which function is used to display output in Python?
(A) display()
(B) output()
(C) print()
(D) show()
Answer: (C) print()
8. Which function is used to take input from the user in Python?
(A) get()
(B) input()
(C) read()
(D) scan()
Answer: (B) input()
9. Which of the following is a valid Python data type?
(A) Integer
(B) String
(C) List
(D) All of the above
Answer: (D) All of the above
10. Which of the following is used to represent a Boolean value in Python?
(A) Yes and No
(B) True and False
(C) 1 and 2 only
(D) On and Off
Answer: (B) True and False
11. Python is an open-source language. What does this mean?
(A) Its source code is publicly available
(B) It can only be used online
(C) It cannot be modified
(D) It is available only to companies
Answer: (A) Its source code is publicly available
12. Which function is used to determine the data type of an object in Python?
(A) datatype()
(B) typeof()
(C) type()
(D) data()
Answer: (C) type()
13. Which of the following is a collection of key-value pairs in Python?
(A) List
(B) Tuple
(C) Dictionary
(D) Set
Answer: (C) Dictionary
14. Python supports which programming approach?
(A) Object-oriented programming
(B) Procedural programming
(C) Functional programming
(D) All of the above
Answer: (D) All of the above
15. Which of the following is a feature of Python?
(A) Complex syntax
(B) Platform dependency
(C) Readable and simple syntax
(D) It can only be used for web development
Answer: (C) Readable and simple syntax
16. What will be the output for the following Python program? x=3; if (x==0) print “Am I here?”; elif (x==3) print “Or here”; print “Or over here?”
(A) Or here?
(B) Am I here? Or here
(C) Or here? Or over here?
(D) Am I here? Or over here?
Liaison Officer (LO) 2025
Answer: (C) Or here? Or over here?
Kindly provide me notes