Saturday, 12 April 2025

Решение задач №9 КЕГЭ Информатика в пакетном режиме ( Python 3.13.2)

 Рассмотрены примеры

https://inf-ege.sdamgia.ru/problem?id=76677

https://inf-ege.sdamgia.ru/problem?id=55596












(.env) boris@fedora41KDE:~/KEGE2025/KRASN/EXCEL09$ cat djs76677VR-09.py

import openpyxl
import csv
# input excel file path
inputExcel = '/home/boris/Downloads/0976677.xlsx'
newWorkbook = openpyxl.load_workbook(inputExcel)
# getting the active workbook sheet(Bydefault-->Sheet1)
worksheet = newWorkbook.active
# Opening a output csv file in write mode
F = open("result0976677.csv", 'w')
OutCsv = csv.writer(F,delimiter=";")
for eachrow in worksheet.rows:
      OutCsv.writerow([cell.value for cell in eachrow])
F.close()

f = list(map(lambda x: list(map(int, x.split(';'))), \
         open('./result0976677.csv').readlines()))
count = 0
for a in f:
 averg = sum(a)/len(a)
 zeven = [ x for x in a if x%2 == 0 and x > averg ]
 zodd = [ x for x in a if x%2 == 1 and x > averg]
 if len(zodd) < len(zeven):
    if sum(x for x in a if x%2==0) < sum(x for x in a if x%2==1):
                    count += 1
print(count)

(.env) boris@fedora41KDE:~/KEGE2025/KRASN/EXCEL09$ python djs76677VR-09.py

232

(.env) boris@fedora41KDE:~/KEGE2025/KRASN/EXCEL09$ cat djs55596V-09.py

import openpyxl
import csv
# input excel file path
inputExcel = '/home/boris/Downloads/0955596.xlsx'
newWorkbook = openpyxl.load_workbook(inputExcel)
# getting the active workbook sheet(Bydefault-->Sheet1)
worksheet = newWorkbook.active
# Opening a output csv file in write mode
F = open("result0955596.csv", 'w')
OutCsv = csv.writer(F,delimiter=";")
for eachrow in worksheet.rows:
      OutCsv.writerow([cell.value for cell in eachrow])
F.close()
#############################################################
# Solve problem via exporting xlsx file to csv in batch mode
#############################################################
matrix = list(map(lambda x: list(map(int, x.split(';'))), \
         open('./result0955596.csv').readlines()))

allString = []
for string in matrix:

         for z in string:
            allString.append(z)  
okstr = [string for string in matrix \
              if any([string.count(x)==1 and allString.count(x)==46 for x in string])]
print(len(okstr))

(.env) boris@fedora41KDE:~/KEGE2025/KRASN/EXCEL09$ python djs55596V-09.py

445

References

https://statusneo.com/excel-automation-with-pythons-openpyxl-a-comprehensive-guide/


Решение задач №9 КЕГЭ Информатика в пакетном режиме ( Python 3.13.2)

  Рассмотрены примеры https://inf-ege.sdamgia.ru/problem?id=76677 https://inf-ege.sdamgia.ru/problem?id=55596 (.env) boris@fedora41KDE : ~/K...