Monday, July 27, 2026

Week 10 Assignments


Week 10 Notes


# 
# Python Problem Solver
# Week 10 Example 1: Street Construction 
#

n, k = map(int, input().strip().split())

"""if (n-k)%(k+1) == 0:
    print((n-k)//(k+1))
else:
    print((n-k)//(k+1)+1)
"""

print((n)//(k+1))


# 
# Python Problem Solver
# Week 10 Example 2: Bubble Sort
#

N = int(input("Input the number of elements to sort: ").strip())
a = list(map(int, input("Input the elements: ").strip().split()))

for i in range(N):
    for j in range(N-1):
        if a[j] > a[j+1]:
            t = a[j]
            a[j] = a[j+1]
            a[j+1] = t

for i in range(N):
    print(a[i], end=" ")
print()

Term 2 Term Test