Intermediate Level

Print First 10 natural numbers using while loop


cnt = 0

while (cnt := cnt + 1) <= 10: print(cnt)

Print the right-angle triangle pattern


ur_input = int(input("Enter Some Number: "))
for i in range(ur_input + 1):
for j in range(i):
print(i, end=" ")
print()

Print the list in reverse order using loops


lst_ = [i for i in range(5)]

lst_
for i in reversed(lst_):
print(i)
for i in (lst_[::-1]):
print(i)

Print the number from -10 to -1 using loops


for i in range(-10, 0):
print(i)

Remove the objects from set which are common


s1 = {10,20,30,40}

s2 = {30,40,50,60}
res = s1.symmetric_difference(s2)

res