Recursive Traversal Of List
Mon 10 August 2026
def print_list(lst):
if not lst:
return
print(lst[0])
print_list(lst[1:])
print_list([1, 2, 3, 4])
1
2
3
4
Score: 10
Category: chapter8_recursion
Read Moredef print_list(lst):
if not lst:
return
print(lst[0])
print_list(lst[1:])
print_list([1, 2, 3, 4])
1
2
3
4
Score: 10
Category: chapter8_recursion
Read Moreprint(a is b)
Score: 5
Category: chapter1
Read Morea = [1, 2, 3]
b = a
Score: 10
Category: chapter1
Read More# analytics/stats.py
from .utils import format_number
Score: 5
Category: chapter10_modules_and_packages
Read Moreimport math as m
print(m.pi) # Output: 3.141592653589793
3.141592653589793
Score: 10
Category: chapter10_modules_and_packages
Read Moreimport os
os.rename("sample.txt", "renamed.txt")
os.remove("renamed.txt")
Score: 10
Category: chapter12_file_handling
Read Moredef calculate_total(a, b):
return a + b
def main():
result = calculate_total(10, 20)
print("Total:", result)
if __name__ == "__main__":
main()
Total: 30
Score: 10
Category: chapter14_main_function
Read Moreclass Parent:
def show(self):
print("This is the parent class")
class Child(Parent):
pass
c = Child()
c.show()
This is the parent class
Score: 10
Category: chapter2_inheritance
Read Moreimport csv
with open("data.csv", "r") as file:
reader = csv.reader(file)
header = next(reader)
print("Header:", header)
for row in reader:
print(row)
Score: 5
Category: chapter11_csv_handling
Read Moreimport csv
with open("data.csv", "r") as file:
reader = csv.reader(file)
next(reader) # Skip header
for row in reader:
print(row)
['Alice', '25', 'Paris']
['Bob', '30', 'London']
Score: 10
Category: chapter11_csv_handling
Read More