marks = int(input("Enter marks: "))
if marks >= 90:
print("Grade A")
elif marks >= 75:
print("Grade B")
elif marks >= 50:
print("Grade C")
else:
print("Fail")
---
2. Program to find largest among three numbers using nested if.
a = int(input())
b = int(input())
c = int(input())
if a > b:
if a > c:
print("A is largest")
else:
print("C is largest")
else:
if b > c:
print("B is largest")
else:
print("C is largest")
---
3. Differentiate break and continue with examples. (6 marks)
break: stops loop
for i in range(1,6):
if i == 3:
break
print(i)
continue: skips current iteration
for i in range(1,6):
if i == 3:
continue
print(i)
---
4. Demonstrate pass statement. (6 marks)
Used as a placeholder.
for i in range(5):
pass # does nothing
def fun():
pass
---
5. Discuss len(), capitalize(), split(), replace() with examples.
s = "hello world"
print(len(s)) # 11
print(s.capitalize()) # Hello world
print(s.split()) # ['hello', 'world']
print(s.replace("hello","hi")) # hi world
---
6. Demonstrate sort() and set() for comparing lists.
l1 = [3,1,2]
l2 = [2,1,3]
print(sorted(l1) == sorted(l2)) # Using sort
print(set(l1) == set(l2)) # Using set
---
7. Append items to list and find max/min.
l = []
l.append(10)
l.append(5)
l.append(7)
print("Max:", max(l))
print("Min:", min(l))
---
8. Tuple operations: length, list→tuple, compare, first occurrence.
t1 = (1,2,3,2)
t2 = (1,2,3)
print(len(t1)) # length
print(tuple([4,5,6])) # list to tuple
print(t1 == t2) # compare
print(t1.index(2)) # first occurrence
---
9. Column selection, addition, deletion in DataFrame.
import pandas as pd
df = pd.DataFrame({"A":[1,2], "B":[3,4]})
print(df["A"]) # selection
df["C"] = [5,6] # addition
df = df.drop("B", axis=1) # deletion
---
10. Row selection, addition, deletion in DataFrame.
import pandas as pd
df = pd.DataFrame({"A":[1,2], "B":[3,4]})
print(df.loc[0]) # row select
df.loc[2] = [7,8] # add row
df = df.drop(1) # delete row
✅ MODULE Il
Start from the beginning
