Предмет: Информатика, автор: kardakovadariasovt

Нужно написать программы на Питоне

Задание №1

Вычислить средний балл учеников класса, если известны оценки каждого ученика по математике, русскому языку и физике. Распечатать список учеников, имеющих средний балл выше среднего в классе.

Задание №2.

Дана матрица размером nхm. Переставляя ее строки и столбцы, добиться того, что наибольший элемент (или один из них) оказался в верхнем левом углу.

Задание №3.

Создать программу, которая позволяет конвертировать введенные десятичные числа в шестнадцатеричную систему счисления и обратно.

Ответы

Автор ответа: n58hf4b9c4
0

Ответ:

Объяснение:


def calculate_average_score(grades):

   total_scores = sum(grades.values())

   average_score = total_scores / len(grades)

   return average_score

def find_students_above_average(grades):

   average_score = calculate_average_score(grades)

   above_average_students = [student for student, score in grades.items() if score > average_score]

   return above_average_students

# Example grades dictionary

grades = {

   'John': {'math': 90, 'russian': 85, 'physics': 92},

   'Alice': {'math': 75, 'russian': 80, 'physics': 78},

   'Mark': {'math': 82, 'russian': 88, 'physics': 90},

   'Emma': {'math': 95, 'russian': 92, 'physics': 87},

   'Michael': {'math': 88, 'russian': 76, 'physics': 84}

}

above_average_students = find_students_above_average(grades)

average_score = calculate_average_score(grades)

print("Average score in the class:", average_score)

print("Students with above-average score:")

for student in above_average_students:

   print(student)





def find_max_element(matrix):

   max_element = matrix[0][0]

   max_row = 0

   max_col = 0

   for i in range(len(matrix)):

       for j in range(len(matrix[i])):

           if matrix[i][j] > max_element:

               max_element = matrix[i][j]

               max_row = i

               max_col = j

   return max_element, max_row, max_col

def swap_rows(matrix, row1, row2):

   matrix[row1], matrix[row2] = matrix[row2], matrix[row1]

def swap_columns(matrix, col1, col2):

   for i in range(len(matrix)):

       matrix[i][col1], matrix[i][col2] = matrix[i][col2], matrix[i][col1]

def rearrange_matrix(matrix):

   max_element, max_row, max_col = find_max_element(matrix)

   swap_rows(matrix, 0, max_row)

   swap_columns(matrix, 0, max_col)

   return matrix

# Пример матрицы

matrix = [

   [3, 1, 4],

   [1, 5, 9],

   [2, 6, 5]

]

rearranged_matrix = rearrange_matrix(matrix)

print("Матрица после перестановки:")

for row in rearranged_matrix:

   print(row)



def decimal_to_hex(decimal):

   hex_value = hex(decimal)[2:]  # Преобразование в шестнадцатеричную строку и удаление префикса '0x'

   return hex_value.upper()  # Приведение к верхнему регистру

def hex_to_decimal(hex_value):

   decimal = int(hex_value, 16)  # Преобразование из шестнадцатеричной строки в десятичное число

   return decimal

# Преобразование десятичного числа в шестнадцатеричное

decimal_input = int(input("Введите десятичное число: "))

hex_output = decimal_to_hex(decimal_input)

print("Шестнадцатеричное представление:", hex_output)

# Преобразование шестнадцатеричного числа в десятичное

hex_input = input("Введите шестнадцатеричное число: ")

decimal_output = hex_to_decimal(hex_input)

print("Десятичное представление:", decimal_output)

Похожие вопросы
Предмет: Математика, автор: karpunovaroslav1
Предмет: Английский язык, автор: egoryashin24
15. Where you (to be) yesterday? – I (to be) at home the whole day. – How strange, I (to ring) you up at 2 o’clock, but nobody (to answer).
16. Listen! Somebody (to cry).
17. I (to like) music very much.
18. Where your sister (to be) now? – She (to be) in her room. She (to do) her homework.
19. We (to go) home now because it (to be) late.
20. Who you (to wait) for?
21. We (to be) very tired yesterday and (to want0to sleep, that’s why we (to decide) to go home.
22. This famous sportsman (to break) world records every year!
23. Listen! The sisters (to sing) that beautiful song again.
24. My school football team (not to win) a competition last month.
25. My little brother always (to go) to sleep on time when he was a school boy.
26. (to go) you to be an actor?
27. (to read) you already this book by Kipling? – Yes, would you like to take it?
28. He (to get) the leading role in the performance yesterday.
29. I (to read) just this book. It’s really worth reading.
30. The train to Oxford already (to go). The next train is in the half an hour.
31. Martin (to walk) back and forward at the moment. He is nervous about the game.
32. My father (to walk) a dog in the evening every day.
33. What you (to do)? Can we go for a walk now? – My homework. I’ll call you in half an hour.
34. We (not to go) fishing with my uncle last month.
35. I (to go) to bed at 9 p.m. I promise, Mum!
36. You (to come) to my birthday party on Sunday?
37. My sister always (to help) mother to cook our meals.
38. My elder brother (not to visit) many foreign countries yet.
39. I (to do) all the exercises already.
40. At summer camp we (to sail) on boats, I think.
41. My friends (to go) hiking last week.

100 баллов