PYTHON PROGRAMMING — ANSWER SHEET
UNIT 1 — INTRODUCTION TO PYTHON
History, features, data types, operators, type conversion, variables, keywords, and basic programs.
UNIT 2 — PYTHON DATA TYPES & STRING/LIST/TUPLE/DICT
Strings, lists, tuples, dictionaries, slicing, methods, and examples.
UNIT 3 — FUNCTIONS AND MODULES
Function types, arguments, return statement, lambda, modules, scope, and examples.
UNIT 4 — OOP & PYTHON LIBRARIES
Classes, objects, constructor, inheritance, polymorphism, libraries: NumPy, Pandas, Matplotlib.
Example Answer — Sum of Two Numbers
a = float(input('Enter first number: '))
b = float(input('Enter second number: '))
print('Sum =', a + b)
Example Answer — Check Positive or Negative
n = float(input('Enter number: '))
if n > 0:
print('Positive')
elif n == 0:
print('Zero')
else:
print('Negative')
Example — Class and Object (OOP)
class Student:
def __init__(self, name, age):
[Link] = name
[Link] = age
def display(self):
print('Name:', [Link], 'Age:', [Link])
s = Student('Asha', 20)
[Link]()