第3級総合無線通信士 過去問編集用スクリプト

めもめも

 

こういう問題の文字列を入力として

↓のように出力したい

 





周波数の偏差及び安定度
周波数の偏差及び幅
周波数の偏差及び幅
周波数の偏差及び安定度
高調波の強度等
空中線電力の偏差等
高調波の強度等
空中線電力の偏差等
重要無線通信に混信
重要無線通信に混信
他の無線設備の機能に支障
他の無線設備の機能に支障

 

python3

# 入力の文字列 input_string = """1 周波数の偏差及び安定度 高調波の強度等 重要無線通信に混信 2 周波数の偏差及び幅 空中線電力の偏差等 重要無線通信に混信 3 周波数の偏差及び幅 高調波の強度等 他の無線設備の機能に支障 4 周波数の偏差及び安定度 空中線電力の偏差等 他の無線設備の機能に支障""" # Split the input string by spaces words = input_string.split() # Join the words with spaces and introduce newline characters after each number output_string = ' '.join(words).replace(' ', '\n') print(output_string) # 改行ごとに分割 lines = output_string.split('\n') # 出力用の行番号 output_line_numbers = [1, 2, 3, 4] # 行ごとに出力 for line_number in output_line_numbers: for i in range(1, 5): print(lines[line_number - 1 + (i - 1) * 4])