generate functionThu, 03 Aug 2023

Continuemos con Excel Crea una lista que contenga los siguientes datos olímpicos (nombre del país y medallas de oro, plata y bronce): USA, 46, 12, 5 China, 38, 20, 7 UK, 29, 7, 7 Russia, 22, 10, 9 South Korea, 13, 3, 2 Germany, 11, 7, 4 Añadir esa lista a la hoja de olimpiadas que creamos en el ejercicio anterior Listar por filas y columnas el contenido Mover todo el rango de datos una fila hacia abajo (buscar en la documentación como mover rangos) Añadir unas cabeceras en la primera línea (que acaba de quedar libre) que sean "Pais", "Oros", "Platas", "Bronces" Guarda los cambios y comprueba en el excel si se han efectuado

import openpyxl # Open the workbook wb = openpyxl.load_workbook('Olimpiadas.xlsx') # Get the worksheet olimpiadas = wb.get_sheet_by_name('Olimpiadas') # Get the first row from the spreadsheet row = olimpiadas[1] print(row) # Iterate over the cells in the first row for cell in row: print(cell) # Get the value of a specific cell pais = olimpiadas['A2'].value print(pais) # Get the value of a specific cell medallas = olimpiadas['B2'].value + olimpiadas['C2'].value + olimpiadas['D2'].value print(medallas) # Get the value of a specific cell medallas = olimpiadas.cell(row=2, column=2).value print(medallas) # Get the value of a specific cell medallas = o

Questions about programming?Chat with your personal AI assistant