Series17. A real number B, an integer N and a set of N real numbers ordered in ascending order are given. Output the elements of the set together with the number B, preserving the order of the output numbers.

Solution in Python 3:

import random

B = random.randrange(1,10)
print("B = ",B)
N = random.randrange(1,20)
print("N = ",N)

for i in range(1,N+1):
print(i,end="; ")

print()
flag = True
for i in range(1,N+1):
print(i,end="; ")
if i <= B and B <= i+1 and flag:
print("B:",B,end="; ")
flag = False