Example:
my_list = [1,2,3]
my_tuple = (1,2,3)
---
3. Demonstrate identity operators with example. (6 marks)
Identity operators compare memory locations.
Operators:
is
is not
Example:
a = [1,2,3]
b = a
c = [1,2,3]
print(a is b) # True – same memory
print(a is c) # False – different memory
print(a is not c) # True
---
4. Demonstrate membership operators with example. (6 marks)
Operators:
in
not in
Example:
numbers = [10,20,30]
print(10 in numbers) # True
print(40 not in numbers) # True
print("a" in "apple") # True
---
5. Demonstrate the format() method with example. (6 marks)
format() helps insert values inside strings.
Example:
name = "Ram"
age = 20
print("My name is {} and I am {} years old".format(name, age))
Positional formatting:
print("{1} is {0} years old".format(20, "Ram"))
Keyword formatting:
print("Name: {n}, Age: {a}".format(n="Ram", a=20))
---
------------------------------------------
📌 PART – C (8 MARKS EACH)
------------------------------------------
1. Illustrate the Python built-in core data types. (8 marks)
Python supports the following core data types:
---
1️⃣ Numeric types
int – whole numbers
float – decimal numbers
complex – with real & imaginary part
Example:
a = 10
b = 12.5
c = 3 + 5j
---
2️⃣ String (str)
Sequence of characters enclosed in quotes.
Example:
name = "Python"
---
3️⃣ List
Ordered, mutable collection.
l = [1, 2, "hi"]
---
4️⃣ Tuple
Ordered, immutable collection.
t = (10, 20, 30)
---
5️⃣ Set
Unordered, unique elements.
s = {1, 2, 3}
---
6️⃣ Dictionary
Stores data as key:value pairs.
d = {"name": "Ram", "age": 20}
---
7️⃣ Boolean (True, False)
Example:
x = True
---
2. Demonstrate different types of operators with examples. (8 marks)
1️⃣ Arithmetic operators:
+ - * / % // **
Example:
a = 10
b = 3
print(a ** b)
2️⃣ Relational operators:
< > <= >= == !=
Example:
print(10 > 5)
3️⃣ Logical operators:
and or not
4️⃣ Assignment operators:
= += -= *= /=
5️⃣ Membership operators:
in, not in
6️⃣ Identity operators:
is, is not
---
3. Illustrate input and output operations with examples. (8 marks)
Input:
Using input()
name = input("Enter name: ")
Output:
Using print()
print("Welcome", name)
Multiple values:
print("Roll:", 101, "Dept:", "CS",)
---
4. Examine type conversion and its types with suitable program. (8 marks)
Python supports:
---
1️⃣ Implicit conversion
Done automatically.
x = 10
y = 5.5
z = x + y # int → float
---
2️⃣ Explicit conversion
User converts manually.
int()
float()
str()
tuple()
list()
Example:
a = "10"
b = int(a)
c = float(a)
print(b + 5)
✅ MODULE l
Start from the beginning
