ARUNACHALA
ARTS & SCIENCE (WOMEN)COLLEGE
‘Kanakammal Gardens’,Vellichanthai,
Kanyakumari District - 629 203.
[Affiliated to Manonmaniam Sundaranar University, Tirunelveli.]
Department of Artificial Intelligence
Internal Examination-I
Programming with Python
Class: II [Link]. (AI) Date: 2025
[Link]
Duration:1Hrs
Part-A (2×1=2)
I Choose the Correct Answer
1. Which of the following is a literal in Python?
a. if b. "Hello" c. print () [Link] ()
2. Which of the following is a feature of Python?
a. Low-level programming b. Complex syntax c. interpreted language
d. Manual memory management
Part-B (2×5=10)
II Answer the following Questions
3. Differentiate between literals, constants, and variables in Python with suitable examples.
4. Explain some important features of Python programming language with examples.
Part-C (1×8=8)
III Answer the following Question
5. Explain how arrays are defined and processed in Python. Illustrate your answer with suitable examples.
Answer Key -Internal Exam I
Part-A
1.b) “Hello”
2. c) interpreted language
Part-B
3. Literals:
A literal is a fixed value that is directly written in the code. It represents data that doesn’t change
during program execution.
Python has several types of literals: numeric, string, Boolean, special, and collection literals.
a = 10 # Numeric literal (integer)
b = 3.14 # Numeric literal (float)
c = 'Hello' # String literal
d = True # Boolean literal
e = None # Special literal
f = [1, 2, 3] # List literals
Here, 10, 3.14, 'Hello', True, None, and [1, 2, 3] are literals.
Constants: A constant is a variable whose value should not be changed once assigned.
Python doesn’t have true constants (unlike languages like C or Java), but by convention, constants
are written in uppercase letters to indicate that their values should remain unchanged throughout the
program.
PI = 3.14159
MAX_USERS = 100
Here, PI and MAX_USERS are constant by convention. Although Python allows their values to
change, programmers avoid doing so.
Variables: A variable is a name that is used to store a value. Unlike constants, variables can be
changed (mutated) during program execution.
x=5
x = x + 3 # variable value changed to 8
name = "Alice"
name = "Bob" # variable value changed to "Bob"
4. 1. Simple and Easy to Learn
Python has a very simple and readable syntax. It is close to English, making it easy for beginners to
learn and use.
Example:
print("Hello, World!")
Easy to understand and write compared to many other languages.
2. Interpreted Language
Python does not require compilation. It is interpreted line by line, which makes debugging easier.
Example:
python [Link]
The Python interpreter executes the program directly without needing a separate compilation step.
3. Dynamically Typed
You don’t need to declare variable types explicitly. The type is determined at runtime.
Example:
x = 10 # integer
x = "Hello" # now x is a string
No need for type declaration like in C or Java.
[Link]-Oriented
Python supports object-oriented programming (OOP) concepts such as classes, objects, inheritance, and
polymorphism.
Example:
class Student:
def __init__(self, name):
[Link] = name
s1 = Student("Alice")
print([Link])
Everything in Python is an object.
5. Extensive Standard Library
Python comes with a rich set of built-in modules and functions that help in file handling, regular
expressions, web services, databases, etc.
Example:
import math
print([Link](16))
No need to write extra code for common tasks.
[Link] Independent
Python is cross-platform, meaning a Python program can run on different operating systems (Windows,
macOS, Linux) without modification.
Example:
A script written on Windows can run on Linux without changes.
[Link]-Level Language
Python abstracts away complex details like memory management, making it easy to focus on
programming logic.
Example:
No need to manually allocate or free memory. Python handles it automatically.
Part-C
5. An array is a collection of elements of the same data type, stored under a single [Link] are useful for
storing large amounts of data and performing mathematical or logical operations efficiently. In Python, arrays
are not part of the core language but can be created using the array module or libraries like NumPy.
Defining an Array
To create an array, we must import the array module and specify:
Type code → defines the type of elements (e.g., 'i' for integer, 'f' for float)
Initial values → given in square brackets []
Syntax:
import array
array_name = [Link](typecode, [initial_values])
Accessing Array Elements
Array elements are accessed using index positions, starting from 0.
Example:
print(numbers[0]) # Output: 10
print(numbers[3]) # Output: 40
Modifying Array Elements
Elements in an array can be changed using indexing.
Example:
numbers[1] = 25
print(numbers) # Output: array('i', [10, 25, 30, 40, 50])
Adding and Removing Elements
Adding Elements
[Link](60) # Adds an element at the end
[Link](2, 15) # Inserts 15 at index 2
print(numbers) # Output: array('i', [10, 25, 15, 30, 40, 50, 60])
Removing Elements
[Link](3) # Removes element at index 3
[Link](50) # Removes first occurrence of 50
print(numbers) # Output: array('i', [10, 25, 15, 40, 60])