# SergioLearns > Programación explicada por un estudiante de Ciencia e Ingeniería de Datos de la ULPGC. ## Posts - [Sobrecarga de operadores en Python — ejercicios para dominar los métodos mágicos](https://sergiolearns.com/sobrecarga-de-operadores-en-python-ejercicios/): La sobrecarga de operadores en Python ejercicios con solución cierran este bloque. Ya viste la teoría y practicaste con clases reales. Ahora toca resolver por tu cuenta. Dos ejercicios en tres niveles con especial atención al error más traicionero, implementar __rsub__ o __rtruediv__ como si la operación fuera conmutativa cuando no lo es. Recuerda revisar... - [Sobrecarga de operadores en Python — 2 clases reales con todos los operadores](https://sergiolearns.com/sobrecarga-de-operadores-en-python-practica/): La sobrecarga de operadores en Python práctica real es lo que toca ahora. En el artículo anterior vimos la teoría. Ahora construimos dos clases completas con todos los operadores, número racional y dinero con conversión de moneda. Recuerda que usando pythontutor.com, puedes también visualizar tu código. Sobrecarga de operadores en Python práctica — Programa 1:... - [Sobrecarga de operadores en Python — métodos mágicos para clases propias](https://sergiolearns.com/sobrecarga-de-operadores-en-python/): La sobrecarga de operadores en Python permite que tus clases propias funcionen con los operadores habituales (+, -, *, ==, <, >) igual que los tipos predefinidos. En FP2 es el tema que más confunde porque mezcla métodos mágicos, herencia y polimorfismo en un mismo concepto. En este artículo lo vemos todo con una clase... - [Herencia en Python — ejercicios para dominar jerarquías de clases](https://sergiolearns.com/herencia-en-python-ejercicios/): La herencia en Python ejercicios con solución cierran este bloque. Ya viste la teoría y practicaste con jerarquías reales. Ahora toca resolver por tu cuenta. Dos ejercicios en tres niveles de dificultad con especial atención al error más común en FP2 olvidar llamar a super().__init__() en la subclase y quedarse con atributos de la superclase... - [Herencia en Python — 3 jerarquías de clases reales con polimorfismo](https://sergiolearns.com/herencia-en-python-practica/): La herencia en Python práctica real es lo que toca ahora. En el artículo anterior vimos la teoría. Ahora construimos tres jerarquías de clases reales, cada una demuestra un aspecto diferente de la herencia y el polimorfismo. Usa pythontutor.com para visualizar el funcionamiento de lo practicado. Herencia en Python práctica — Programa 1: Sistema de... - [Herencia y polimorfismo en Python — super(), override y clases abstractas](https://sergiolearns.com/herencia-en-python/): La herencia en Python es el mecanismo que permite crear nuevas clases a partir de clases existentes. En vez de escribir el mismo código dos veces, defines lo común en una clase base y lo específico en las subclases. En este artículo vemos herencia, super(), override, polimorfismo, clases abstractas e isinstance, todo lo que entra... - [Clases en Python — ejercicios para dominar objetos y encapsulamiento](https://sergiolearns.com/clases-en-python-ejercicios/): Las clases en Python ejercicios con solución cierran este bloque. Ya viste la teoría y practicaste con programas reales. Ahora toca resolver por tu cuenta. Tres niveles con especial atención al error más común, modificar atributos privados directamente desde fuera de la clase saltándose el setter y perdiendo toda la validación. Cuentas con pythontutor.com para... - [Clases en Python — 3 programas reales con encapsulamiento y @property](https://sergiolearns.com/clases-en-python-practica/): Las clases en Python práctica real es lo que toca ahora. En el artículo anterior vimos la teoría. Ahora construimos tres clases desde cero, empezando sin encapsulamiento y añadiéndolo progresivamente para que veas exactamente por qué mejora el código. Clases en Python práctica — Programa 1: Clase CuentaBancaria Empezamos con la versión básica sin encapsulamiento:... - [Clases en Python — objetos, encapsulamiento y métodos mágicos desde cero](https://sergiolearns.com/clases-en-python/): Las clases en Python son el mecanismo central de la Programación Orientada a Objetos (POO), el paradigma que domina FP2. Una clase es un molde para crear objetos que agrupan datos y comportamiento en una sola unidad. En este artículo vemos cómo definir clases, inicializarlas con __init__, proteger sus datos con encapsulamiento y dar representaciones... - [Excepciones en Python — ejercicios para escribir código que no se rompe](https://sergiolearns.com/excepciones-en-python-ejercicios/): Las excepciones en Python ejercicios con solución cierran este bloque. Ya viste la teoría y practicaste con programas reales. Ahora toca resolver por tu cuenta. Tres niveles de dificultad con especial atención al error más común de FP2, capturar Exception genérico en vez de excepciones específicas, ocultando errores reales en el código. Corrige los errores,... - [Excepciones en Python — 4 programas reales que no se rompen](https://sergiolearns.com/excepciones-en-python-practica/): Las excepciones en Python práctica real es lo que toca ahora. En el artículo anterior vimos la teoría. Ahora escribimos cuatro programas que no se rompen ante ninguna entrada inesperada. Cada uno demuestra un uso real de las excepciones que verás en FP2. Excepciones en Python práctica — Programa 1: Validador robusto de datos El... - [Excepciones en Python — try, except, raise y assert sin rodeos](https://sergiolearns.com/excepciones-en-python/): Las excepciones en Python son el mecanismo que permite a un programa gestionar situaciones inesperadas sin romperse. En FP1 aprendiste a prevenir errores con if/else. En FP2 das un paso más, aprendes a capturarlos cuando ocurren y a lanzarlos tú mismo cuando es necesario. En este artículo vemos todo: try/except, excepciones específicas y genéricas, finally,... - [Punteros en C — ejercicios para dominar la memoria](https://sergiolearns.com/punteros-en-c-ejercicios/): Los punteros en C ejercicios con solución cierran este bloque. Ya viste la teoría y practicaste con programas reales. Ahora toca resolver por tu cuenta con gedit y gcc en Fedora. Cuatro ejercicios en tres niveles con especial atención al error más peligroso de todos, usar un puntero sin inicializar. Revisa tus códigos con pythontutor.com.... - [Punteros en C — 4 programas reales para perderles el miedo](https://sergiolearns.com/punteros-en-c-practica/): Los punteros en C práctica real es lo que toca ahora. En el artículo anterior vimos la teoría. Ahora abre gedit en Fedora y escribe el código mientras lees. Cuatro programas progresivos, cada uno demuestra un uso real de los punteros que verás en IC2. Recuerda el flujo: Nota — funciones en C En estos... - [Punteros en C — direcciones de memoria sin misterio](https://sergiolearns.com/punteros-en-c/): Los punteros en C son el tema que más miedo da en IC2, y el que más diferencia a C de cualquier otro lenguaje que hayas visto antes. En Python nunca piensas en memoria, simplemente asignas valores y Python se encarga del resto. En C tú eres el responsable de saber dónde está cada dato... - [Bucles en C — ejercicios para dominar for, while y do…while](https://sergiolearns.com/bucles-en-c-ejercicios/): Los bucles en C ejercicios con solución cierran este bloque. Ya viste la teoría y practicaste con programas reales. Ahora toca resolver por tu cuenta con gedit y gcc en Fedora. Cuatro ejercicios en tres niveles con especial atención al error más silencioso de los bucles, el punto y coma después del for o while... - [Bucles en C — 3 programas reales con for, while y do…while](https://sergiolearns.com/bucles-en-c-practica/): Los bucles en C práctica real es lo que toca ahora. En el artículo anterior vimos la teoría de for, while y do...while. Ahora abre gedit en Fedora y escribe el código mientras lees. Tres programas progresivos, cada uno usa el bucle más apropiado para su caso. Recuerda el flujo: Bucles en C práctica —... - [Bucles en C — for, while y do…while sin rodeos](https://sergiolearns.com/bucles-en-c-for-while/): Los bucles en C for while y do…while son las estructuras que te permiten repetir código. Si vienes de Python ya conoces for y while, pero en C la sintaxis es muy diferente y hay un tercero que Python no tiene: el do...while. En este artículo vemos los tres, cuándo usar cada uno y los... - [Condicionales en C — ejercicios para dominar if, else y switch](https://sergiolearns.com/condicionales-en-c-ejercicios/): Los condicionales en C ejercicios con solución cierran este bloque. Ya viste la teoría y practicaste con programas reales. Ahora toca resolver por tu cuenta con gedit y gcc en Fedora. Tres niveles de dificultad con especial atención al error más silencioso de los condicionales en C, olvidar las llaves y crear bloques incompletos sin... - [Condicionales en C — 3 programas reales en gedit y Fedora](https://sergiolearns.com/condicionales-en-c-practica/): Los condicionales en C práctica real es lo que toca ahora. En el artículo anterior vimos la teoría de if/else if/else y switch/case. Ahora abre gedit en Fedora y escribe el código mientras lees. Tres programas progresivos con capturas reales de mi terminal. Recuerda el flujo: Condicionales en C práctica — Programa 1: Clasificador de... - [Condicionales en C — if, else if, else y switch sin rodeos](https://sergiolearns.com/condicionales-en-c-if-else-switch/): Los condicionales en C if else switch son la base de cualquier programa que tome decisiones. Si vienes de Python ya conoces la lógica, la diferencia está en la sintaxis. En C los paréntesis en la condición son obligatorios, las llaves delimitan los bloques y el switch/case tiene un comportamiento que sorprende a todo el... - [Tipos y variables en C — ejercicios para dominar printf, scanf y operadores](https://sergiolearns.com/tipos-y-variables-en-c-ejercicios/): Los tipos y variables en C ejercicios con solución son el cierre perfecto de este primer bloque. Ya viste la teoría y practicaste con programas reales. Ahora toca resolver por tu cuenta con gedit y gcc en Fedora. Cuatro ejercicios en tres niveles con especial atención al error del & en scanf, el más silencioso... - [Tipos y variables en C — 3 programas reales en gedit y Fedora](https://sergiolearns.com/tipos-y-variables-en-c-practica/): Los tipos y variables en C práctica real es lo que toca ahora. En el artículo anterior vimos la teoría. Ahora abre gedit en Fedora y escribe el código mientras lees, es la única forma de que se quede. Tres programas progresivos con capturas reales de mi terminal. Recuerda el flujo de trabajo: Tipos y... - [Tipos y variables en C — lo que cambia respecto a Python y lo que no](https://sergiolearns.com/tipos-y-variables-en-c/): Los tipos y variables en C son lo primero que necesitas dominar para programar en IC2. Si vienes de Python, algunas cosas te sonarán, los operadores son casi iguales, pero hay diferencias importantes que si no entiendes bien te van a dar errores durante semanas. En este artículo vemos los tipos básicos, cómo declarar variables,... - [C en Fedora — instala gedit, compila con gcc y escribe tu primer programa](https://sergiolearns.com/instalar-gedit-en-fedora-y-compilar-con-gcc/): Instalar gedit en Fedora y compilar con gcc fue lo primero que tuve que resolver en IC2. Cuando nos dijeron que ibamos a programar en C usando gedit, lo primero que hice fue abrir la terminal de Fedora y escribir gedit. La respuesta fue inmediata: command not found. Nadie me había avisado de que había... - [Comandos básicos de Linux — ejercicios para soltar la mano en la terminal](https://sergiolearns.com/comandos-basicos-de-linux-ejercicios/): Los comandos básicos de Linux ejercicios con solución son el cierre perfecto de este primer bloque. Ya viste la teoría y practicaste con ejercicios guiados. Ahora toca resolver por tu cuenta con Fedora abierta. Cuatro ejercicios en tres niveles , con especial atención al error de confundir > con >> que destruye ficheros sin avisar.... - [Comandos básicos de Linux — practica navegando por Fedora](https://sergiolearns.com/comandos-basicos-de-linux-practica/): Los comandos básicos de Linux práctica real es lo que toca ahora. En el artículo anterior vimos la teoría. Ahora abre tu Fedora en VirtualBox y ejecuta los comandos mientras lees, es la única forma de que se queden. Tres ejercicios progresivos con capturas reales de mi terminal. Antes de empezar — prepara tu terminal... - [Comandos básicos de Linux — los que usas cada día en IC2](https://sergiolearns.com/comandos-basicos-de-linux/): Los comandos básicos de Linux son lo primero que necesitas dominar cuando abres la terminal en IC2. Sin ellos no puedes hacer nada, no puedes moverte por el sistema de archivos, crear carpetas para tus prácticas ni gestionar tus ficheros de código. En este artículo vemos los comandos que más usarás, con ejemplos reales ejecutados... - [Linux para estudiantes — todo lo que nadie te explica antes de IC2](https://sergiolearns.com/linux-para-estudiantes/): Cuando me dijeron en Ingeniería de Computadores II que íbamos a trabajar con Linux, mi primera reacción fue «¿por qué no usamos Windows como siempre?». Si estás en esa misma situación, este artículo es para ti. Aquí explico todo lo que me hubiera gustado saber antes de abrir la terminal por primera vez, sin tecnicismos... - [Funciones en Python — ejercicios para afianzar lo que sabes](https://sergiolearns.com/funciones-en-python-ejercicios/): Las funciones en Python ejercicios con solución son el cierre perfecto de este tema. Ya viste la teoría y practicaste con programas reales. Ahora toca resolver por tu cuenta. Cuatro ejercicios en tres niveles con especial atención al error más silencioso de todos: olvidar el return y trabajar sin darte cuenta con None. Como siempre:... - [Funciones en Python — 3 programas que demuestran su poder real](https://sergiolearns.com/funciones-en-python-practica/): Las funciones en Python práctica real es lo que toca ahora. En el artículo anterior vimos la teoría. Ahora construimos tres programas desde cero en VS Code donde las funciones no son opcionales, son la razón por la que el código funciona bien. Empezamos comparando el mismo programa sin funciones y con funciones para que... - [Funciones en Python — deja de repetir código de una vez](https://sergiolearns.com/funciones-en-python/): Las funciones en Python son la herramienta que te permite dejar de repetir código. Hasta ahora cada vez que necesitabas hacer lo mismo en dos sitios del programa copiabas y pegabas. Con funciones escribes el código una vez, le das un nombre, y lo llamas desde cualquier parte. Es uno de los conceptos más importantes... - [Bucles en Python — ponlos a prueba con estos ejercicios](https://sergiolearns.com/bucles-en-python-ejercicios/): Los bucles en Python ejercicios con solución son el último paso para dominar for y while. Ya viste la teoría y practicaste con programas reales. Ahora toca resolver por tu cuenta. En este artículo encontrarás cuatro ejercicios en tres niveles: básico, intermedio y desafío final, con especial atención al error del bucle infinito por olvidar... - [Bucles en Python — 3 programas que por fin tienen sentido](https://sergiolearns.com/bucles-en-python-practica/): Los bucles en Python práctica real es lo que toca ahora. En el artículo anterior vimos la teoría de for y while. Ahora construimos tres programas desde cero en VS Code: un validador de contraseña con intentos limitados, una calculadora de factorial y una cuenta atrás. Además comparamos cómo el mismo problema se resuelve con... - [Bucles en Python — for y while sin rodeos](https://sergiolearns.com/bucles-en-python/): Los bucles en Python for y while son la herramienta que le da a tu código la capacidad de repetirse. Sin bucles tendrías que escribir la misma instrucción cien veces para hacer algo cien veces. Con bucles lo haces en tres líneas. Es uno de los conceptos más importantes de FP1 y también uno de... - [Condicionales en Python — ejercicios con solución y chuletario completo](https://sergiolearns.com/condicionales-en-python-ejercicios/): Los condicionales en Python ejercicios con solución son la mejor forma de afianzar if, elif y else. Ya viste la teoría y practicaste con programas reales. Ahora toca resolver por tu cuenta. En este artículo encontrarás cuatro ejercicios en tres niveles de dificultad, con especial atención al error de confundir and con or en condiciones... - [Condicionales en Python — práctica real con 3 programas en VS Code](https://sergiolearns.com/condicionales-en-python-practica/): Los condicionales en Python práctica real es lo que toca ahora. En el artículo anterior vimos la teoría de los condicionales en Python. Ahora toca escribir código real. En este artículo construimos tres programas desde cero en VS Code usando if, elif y else en situaciones reales: un validador de formulario de registro, un sistema... - [Condicionales en Python — if, elif y else sin complicaciones](https://sergiolearns.com/condicionales-en-python/): Los condicionales en Python if elif else son la primera herramienta que le da inteligencia a tu código. Hasta ahora tus programas ejecutaban todas las líneas en orden, de arriba a abajo, sin tomar ninguna decisión. Con los condicionales puedes hacer que Python ejecute unas instrucciones u otras dependiendo de si se cumple una condición.... - [Depuración en Python — encuentra errores sin volverte loco](https://sergiolearns.com/depurar-en-python/): Depuración en Python es una de las habilidades más importantes que nadie te enseña directamente en primero. Sabes escribir código, pero cuando algo falla, y siempre falla, no sabes por dónde empezar a buscar. En este artículo te explico cómo depurar en Python usando las tres herramientas que más uso: Thonny, Python Tutor y el... - [Operadores en Python — ejercicios reales con solución y chuletario](https://sergiolearns.com/operadores-en-python-ejercicios/): Los operadores en Python ejercicios con contexto real son la mejor forma de afianzar lo que vimos en teoría y práctia. En este artículo encontrarás cinco ejercicios en tres niveles de dificultad: básico, intermedio y desafío final, con especial foco en % y // que son los operadores que más confunden. Como siempre: intenta resolverlo,... - [Operadores en Python — práctica real con 3 programas en VS Code](https://sergiolearns.com/operadores-en-python-practica/): Los operadores en Python práctica real es lo que toca ahora, en el artículo anterior vimos la teoría. Ahora toca escribir código real. En este artículo construimos tres programas desde cero en VS Code usando todos los operadores que aprendiste: un conversor de unidades, una calculadora de descuentos y una calculadora completa con menú. Cada... - [Operadores en Python — los errores que todo el mundo comete](https://sergiolearns.com/operadores-en-python/): Si ya tienes claro lo de las variables y tipos de datos, el siguiente paso natural son los operadores en Python. Son las herramientas que te permiten hacer cálculos, comparar valores y tomar decisiones en tu código. En este artículo vemos todos los tipos de operadores que necesitas conocer en primero, con los tres errores... - [Carpeta compartida entre Windows y Fedora en VirtualBox — guía completa](https://sergiolearns.com/carpeta-compartida-entre-windows-y-fedora/): Una vez tienes Fedora funcionando en VirtualBox, lo siguiente que necesitas es poder pasar archivos entre Windows y Fedora sin complicaciones. En IC2 esto es fundamental, escribes código en Fedora pero quizás quieres tenerlo también en Windows para hacer copia de seguridad o entregarlo. En este artículo configuramos la carpeta compartida entre Windows y Fedora... - [Cómo instalar Fedora en VirtualBox — guía paso a paso para estudiantes](https://sergiolearns.com/instalar-fedora-en-virtualbox/): Instalar Fedora en VirtualBox fue una de las primeras cosas que nos pidieron en Ingeniería de Computadores II en la ULPGC. Parece sencillo pero hay varios pasos donde es fácil perderse si nadie te guía. En esta guía te explico cómo instalar Fedora en VirtualBox desde cero, con cada decisión explicada para que entiendas qué... - [Lo que necesitas saber de informática antes de empezar a programar](https://sergiolearns.com/informatica-basica-antes-de-programar/): Cuando entré a GCID pensaba que programar era solo escribir código. Pero las primeras semanas me di cuenta de que hay un montón de conceptos básicos de informática que todo el mundo asume que ya sabes, y que nadie te explica directamente. En este artículo te cuento exactamente lo que necesitas tener claro antes de... - [Variables y tipos de datos en Python — ejercicios con solución y chuletario](https://sergiolearns.com/variables-y-tipos-de-datos-en-python-ejercicios/): Ya viste la teoría y practicaste con código real. Ahora toca el momento de la verdad: resolver ejercicios tú solo. En este artículo encontrarás ejercicios de variables y tipos de datos en Python de nivel intermedio, un ejercicio desafío final que mezcla todo el tema, y un chuletario completo para tener siempre a mano. La... - [Variables y tipos de datos en Python — práctica real con VS Code](https://sergiolearns.com/variables-y-tipos-de-datos-en-python-practica/): En el artículo anterior vimos la teoría de las variables y tipos de datos en Python. Ahora toca lo bueno: escribir código real. En este artículo construimos dos programas desde cero en VS Code: una calculadora de nota media y un calculador del IMC. Son ejemplos simples pero usan todo lo que necesitas saber sobre... - [Variables y tipos de datos en Python — por qué Python piensa diferente](https://sergiolearns.com/variables-y-tipos-de-datos-en-python/): Las variables y tipos de datos en Python fueron de las primeras cosas que me confundieron en GCID. En Python simplemente escribes x = 5 y ya tienes una variable. Sin decirle al ordenador de qué tipo es. Sin declarar nada. Viniendo de no haber programado antes, eso me parecía magia. En este artículo te... - [Cómo instalar y configurar VS Code para Python — las extensiones que uso en la carrera](https://sergiolearns.com/configurar-vs-code-para-python/): Configurar VS Code para Python correctamente es lo primero que deberías hacer antes de escribir una sola línea de código. Cuando me animé a practicar por cuenta propia haciendo mis programas, tardé días en tenerlo bien configurado porque nadie me dijo qué extensiones instalar ni cómo ajustarlo para trabajar cómodo. En este artículo te cuento... - [Cómo instalar Python en Windows y hacer tu primer programa](https://sergiolearns.com/instalar-python-en-windows/): Cuando empecé el Grado en Ciencias e Ingeniería de Datos en la ULPGC, la primera asignatura que me puso delante de un ordenador fue Fundamentos de Programación I (FP1). Durante mi primer año en la carrera, nunca tuve que instalar Python en Windows. Era la propia universidad quien nos facilitaba un entorno online llamado Aulaga... - [Loops in Java — exercises with vowels, grades and the loop that once froze on me](https://sergiolearns.com/en/loops-in-java-exercises-with-vowels-grades-and-the-loop-that-once-froze-on-me/): When I wrote my first nested loop, it froze. It wasn’t an infinite loop from forgetting the condition — I had that part under control — it was that I updated the outer loop’s counter inside the inner loop, so the outer one never moved forward. I had to force-close the terminal. If something similar happens with these exercises, it doesn’t mean you’re bad at this, it means nested loops have that exact trap and you need to see it once to stop falling into it. Here are three loop exercises in Java, from easier to trickier. The last one uses […] - [Java loops practice — text, statistics and patterns](https://sergiolearns.com/en/java-loops-practice/): There’s an FP2 lab exercise that looks trivial until you actually try it: counting how many vowels a sentence has. In Python it was for c in text: and that’s it, no further thought needed. In Java, the first thing you instinctively write is for (char c : text), and the compiler throws back an error you don’t understand: «for-each not applicable to type ‘String'». That’s when you remember that in Java a String can’t be looped over directly, and you need to find a way around it. That workaround is exactly the subject of this practice. We’re going to loop […] - [Java flow control exercises — validation, menus and loops](https://sergiolearns.com/en/java-flow-control-exercises/): In the practice you combined Scanner, if/else and switch in programs that looked like real things. Now it’s your turn to solve on your own. All three exercises circle back to the same idea you already saw: validating input, making decisions based on several conditions and controlling a loop that depends on what the user types. Try to solve them before checking the solution. If you’re stuck for more than 10 minutes, use the hint. Java flow control exercises — Basic Level Exercise 1 — University entry grade validator Write a program that asks for a university entry grade (0-14 in […] - [Java flow control practice — validator, menu and guessing game](https://sergiolearns.com/en/java-flow-control-practice/): There’s a very specific moment in the FP2 lab that almost everyone goes through the same way. You’ve spent half an hour on a program that asks for several pieces of input, everything compiles, everything looks fine… and suddenly the program skips a question. No error. It just carries on as if you had already answered something. That’s when the hunt starts, checking line by line something that looks perfectly correct at first glance. It’s the Scanner buffer trap, and you’re going to trigger it yourself in the first program of this practice, on purpose, so you recognise it instantly the […] - [Java variables exercises — master types, casting and Strings](https://sergiolearns.com/en/java-variables-exercises/): In the practice article we deliberately triggered the three classic variable surprises in Java. Now it’s time to solve on your own — but with a twist: the exercises here won’t focus on exactly the same things as the practice. Integer division, casting and == will appear, but as tools to solve something, not as the main character. That’s what happens in real exams. Three levels, three different contexts. Try to solve them before looking at the solution — even if it’s just 10 minutes wrestling with the compiler. That’s where the real learning happens. Java variables exercises — Basic Level […] - [Java variables practice — the mistakes everyone makes with types](https://sergiolearns.com/en/java-variables-practice/): There’s a moment in the first Java lab that happens to almost everyone. You’ve been writing code for a while, you get to a division, you run the program and the result is… 3. Not 3.5. Not 3.33. Three. A whole number. The number you expected was right there on paper, but Java decided to truncate it without warning. That’s integer division. And it’s just one of three surprises waiting for you when you start mixing types in Java. In this practice we’re going to trigger all three on purpose — so when they show up in the lab you already […] - [Java syntax exercises — write code that works first time](https://sergiolearns.com/en/java-syntax-exercises/): You’ve written three programs in the practice article. Now it’s time to solve on your own. Three exercises, three levels — all with their statement, hints and commented solution at the end. The thread running through all three is the same: the structure comes out automatically, semicolons go where they belong, and printf formats exactly what you want. As always: try to solve it yourself, use the hint if stuck for more than 10 minutes, and compare with the commented solution. Java syntax exercises — Basic Level Exercise 1 — Unit converter Write a complete Java program that asks the user […] - [Java syntax practice — 3 real programs to stop fearing the semicolon](https://sergiolearns.com/en/java-syntax-practice/): In the theory article we covered Java’s structure — class, main method, System.out.println and semicolons. Now it’s time to write real programs from scratch. The goal of this practice is one: make the structure come out automatically without having to think about it, and make the semicolon stop costing you failed compilations. Open VS Code, create a folder syntax_practice and a .java file for each program. Remember: the filename must match the class name exactly, including capitalisation. Java syntax practice — Program 1: Basic calculator with Scanner This program asks the user for two numbers and shows the result of the […] - [Loops in Java — for, for-each and while compared with Python](https://sergiolearns.com/en/java-loops/): Loops in Java work with the same logic as Python — repeat a block of code multiple times. What changes is the syntax and one new addition: the for-each loop that Java has and Python’s for already covers implicitly. If you understood loops in Python and C, Java loops will feel immediately familiar with a few small adjustments. The for loop with index Java’s for loop is identical to C’s — three parts separated by semicolons inside the parentheses: The three parts: int i = 0 — initialisation. Runs once before the loop starts. i < 5 — condition. Checked before […] - [Input and flow control in Java — Scanner, if/else and switch from scratch](https://sergiolearns.com/en/java-flow-control/): Input and flow control in Java cover the tools that make a program interactive and intelligent — reading data from the user and making decisions based on it. If you already know Python’s input(), if/elif/else and C’s switch, you already understand the concepts. What changes is the syntax and one important new class: Scanner. Scanner — reading user input In Python you used input() — a built-in function available anywhere. In Java there’s no built-in equivalent. You need to create a Scanner object and import the class first: Breaking down Scanner scanner = new Scanner(System.in): Scanner — the class name. It […] - [Variables in Java — primitive types, String, final and casting from scratch](https://sergiolearns.com/en/java-variables/): Variables in Java are more explicit than in Python — every variable has a fixed type declared at creation that never changes. In Python you wrote x = 5 and Python figured the type out. In Java you write int x = 5 and the compiler enforces that x will always be an integer. This article covers every type you’ll use in FP2, how they work in memory, and the differences that cause the most confusion when coming from Python. Primitive types — the eight basic types Java has eight primitive types. These are not objects — they’re raw values stored […] - [Java from scratch — class structure, main and basic syntax really explained](https://sergiolearns.com/en/java-from-scratch/): Java from scratch means understanding why every line of the skeleton program looks the way it does — not just copying it blindly. Every FP2 student starts with the same question: why does a program that just prints «Hello» need five lines and three keywords they’ve never seen before? This article answers that, then covers every element of Java’s basic syntax with direct comparisons to Python so nothing feels arbitrary. The minimal Java program — every line explained This is the smallest valid Java program. Let’s take it apart line by line. <strong>public class HelloWorld</strong> In Java every piece of code […] - [How to install Java on Windows — JDK 21 and VS Code ready in 10 minutes](https://sergiolearns.com/en/install-java-on-windows/): Installing Java on Windows is the first step before writing a single line of code in FP2. This guide takes you from a blank Windows machine to a working Java development environment in under 10 minutes — JDK 21 downloaded, installed, verified in the terminal, and VS Code configured with the Java extension pack. What you need to install Java on Windows Java development requires two separate things that beginners often confuse: JDK (Java Development Kit) — the complete toolkit for developing Java programs. It includes the compiler (javac) that converts your .java source files into bytecode, the JVM (Java Virtual […] - [Functions in C exercises — master pass by reference](https://sergiolearns.com/en/functions-in-c-exercises/): Functions in C exercises are where pass by value and pass by reference stop being abstract concepts and become tools you apply automatically. You’ve seen the theory and built three complete programs. Now it’s time to solve challenges on your own — finding the second maximum, deleting an element by position, and merging two sorted arrays. Set up your workspace: As always: try to solve it in gedit, compile with gcc, use the hint if stuck for more than 10 minutes, and compare with the commented solution. Functions in c exercises — Basic Level Exercise 1 — Second maximum Write a […] - [Functions in C practice — 3 real programs that consolidate pass by reference](https://sergiolearns.com/en/functions-in-c-practice/): In the previous article we covered C functions theory. Now it’s time to write real programs. In this article we build three programs from scratch in gedit and compile them with gcc in Fedora — array search, transformations by reference and a statistics calculator. Each one puts pass by value and pass by reference to work in situations where the difference is not just theoretical. Set up your workspace: Functions in C practice — Program 1: Array search functions This program implements a complete set of search functions for integer arrays. All read-only searches pass arrays as const int * — […] - [Functions in C — void, Prototypes andPass by Reference Indispensable Guide](https://sergiolearns.com/en/functions-in-c/): Functions in C work with the same concept as in Python — a named block of code you can reuse — but the syntax is stricter and the way data moves in and out is fundamentally different. In Python you never had to think about whether a function could modify the original variable. In C the distinction between pass by value and pass by reference is explicit, visible in the code, and gets things wrong in interesting ways if you misunderstand it. This article covers everything: declaration, prototypes, void, return, pass by value, pass by reference with pointers, and passing arrays. […] - [Python LinkedList exercises — master linked structures](https://sergiolearns.com/en/python-linkedlist-exercises/): Python LinkedList exercises are where the node-manipulation patterns become automatic. You’ve seen the theory and built three programs. Now it’s time to solve challenges on your own — accessing an element at position N, removing duplicates and detecting cycles. Each one requires a different traversal strategy. As always: try to solve it yourself, use the hint if stuck for more than 10 minutes, and compare with the commented solution. Use pythontutor.com to step through your solution and watch the pointers move. The base class All exercises extend this LinkedList. Start from here: Python LinkedList Exercises — Basic Level Exercise 1 — […] - [Python LinkedList practice — 3 real programs that consolidate the structure](https://sergiolearns.com/en/python-linkedlist-practice/): In the previous article we built the LinkedList from scratch. Now it’s time to extend it with real algorithms. In this article we implement three programs that go beyond basic insert and delete — searching with conditions, insertion sort and reversing a linked list. Each one deepens your understanding of how to traverse and manipulate the node chain. We start from the complete LinkedList class built in the theory article. All three programs add methods to it. The base class Python LinkedList Practice — Program 1: Search and count with conditions This program adds a rich set of search and statistical […] - [Linked structures in Python — LinkedList from scratch without the mystery](https://sergiolearns.com/en/python-linkedlist/): Linked structures are the last FP2 block and the one that carries most weight in the second exam. Most people arrive here with the node concept not quite clicking — they understand the words separately but can’t visualise how the whole chain works. This article starts from absolute zero: what a node actually is, how nodes connect in memory, and how every operation works with step-by-step diagrams. What problem do linked structures solve? When you use a Python list [1, 2, 3, 4, 5], Python stores all elements in consecutive memory positions — like a row of numbered boxes: That has […] - [Python testing exercises — master unittest, black box and TDD](https://sergiolearns.com/en/python-testing-exercises/): Python testing exercises are where testing discipline becomes a natural part of how you write code. You’ve seen the theory and built three complete test suites. Now it’s time to design your own — a black box suite from a specification, identifying and fixing badly designed tests, and a complete TDD implementation. As always: try to solve it yourself, use the hint if stuck for more than 10 minutes, and compare with the commented solution. Run your tests with python -m unittest test_file.py -v. Python testing exercises — Basic Level Exercise 1 — Black box test suite from specification Design a […] - [Python testing practice — black box, white box and TDD with real programs](https://sergiolearns.com/en/python-testing-practice/): In the previous article we covered Python testing theory. Now it’s time to apply it systematically. In this article we build three real test suites — black box testing with equivalence classes, white box testing with flow graph analysis, and a complete TDD cycle building a class from scratch test by test. Each one uses a different strategy with a clear purpose. Python testing practice — Program 1: Black box testing with equivalence classes Black box testing designs test cases from the function’s specification — without looking at the code. The key technique is equivalence partitioning: divide the input space into […] - [Testing in Python — white box, black box, TDD and unittest from scratch](https://sergiolearns.com/en/python-testing-unittest/): Testing in Python is the FP2 topic that takes longest to get started with — not because it’s technically difficult, but because at first it feels like you’re learning to write code about code. Why write tests when you can just run the program and see if it works? This article answers that question properly, then covers everything you need: white box and black box testing, unittest from scratch, test organisation and TDD (Test-Driven Development). Why testing exists — what it actually solves Imagine you’ve built a 500-line program. It works perfectly. Then you add a new feature and now something […] - [Python iterators and generators exercises — master yield and iter](https://sergiolearns.com/en/python-iterators-and-generators-exercises/): Python iterators and generators exercises are where yield and the iterator protocol become tools you reach for automatically. You’ve seen the theory and built three complete programs. Now it’s time to design your own — an arithmetic sequence iterator, a multiple generator and a number classifier. As always: try to solve it yourself, use the hint if stuck for more than 10 minutes, and compare with the commented solution. Use pythontutor.com to step through and watch generators pause and resume at yield. Python iterators and generators exercises — Basic Level Exercise 1 — Arithmetic sequence iterator Implement an ArithmeticSequence class that […] - [Python iterators and generators practice — 3 real programs that make them tangible](https://sergiolearns.com/en/python-iterators-and-generators-practice/): In the previous article we covered Python iterators and generators theory. Now it’s time to build real programs where generators aren’t just a curiosity — they’re the right tool. In this article we implement three programs: an infinite Fibonacci generator, a prime number generator and a custom range iterator class. Each one demonstrates a different aspect of the iterator protocol in action. Python iterators and generators practice — Program 1: Infinite Fibonacci generator The Fibonacci sequence is the canonical example for generators because it’s naturally infinite — there’s no last Fibonacci number. A list-based approach would require deciding in advance how […] - [Iterators and generators in Python — how the for loop works under the hood](https://sergiolearns.com/en/python-iterators-and-generators/): Iterators and generators in Python are the mechanism behind every for loop you’ve ever written. When you write for item in collection: Python is doing several things automatically — and understanding what those things are turns a beginner Python programmer into someone who can design efficient, memory-friendly code. This article covers everything: the iterable/iterator distinction, iter(), next(), __iter__, __next__, StopIteration and yield. What happens when you write a for loop Every time you write this: Python is actually doing this behind the scenes: Two separate concepts are at work here — iterable and iterator — and understanding the difference between them […] - [Python operator overloading exercises — master magic methods](https://sergiolearns.com/en/python-operator-overloading-exercises/): Python operator overloading exercises are where magic methods become instinct. You’ve seen the theory and built two complete classes. Now it’s time to design and implement your own — a complex number class and a polynomial class — both mathematical structures that become natural to use once operators are defined. As always: try to solve it yourself, use the hint if stuck for more than 10 minutes, and compare with the commented solution. Use pythontutor.com to step through and watch operator dispatch in action. Python operator overloading exercises — Basic to Intermediate Level Exercise 1 — Complex number class Implement a […] - [Python operator overloading practice — 2 real classes with all operators](https://sergiolearns.com/en/python-operator-overloading-practice/): In the previous article we covered Python operator overloading theory. Now it’s time to build complete classes that use every operator category. In this article we implement two classes from scratch — a Rational number that supports full arithmetic, and a Money class that handles currencies correctly. Both are real-world design problems where operator overloading is the natural solution, not a trick. Python operator overloading practice — Program 1: Rational number (fraction arithmetic) A rational number is a number expressed as a fraction p/q. Building this class properly requires arithmetic operators, comparison operators, reflected operators, conversion methods and @total_ordering — the […] - [Operator overloading in Python — magicmethods for your own classes](https://sergiolearns.com/en/python-operator-overloading/): Operator overloading in Python is what lets your custom classes behave like built-in types. When you write 3 + 5 Python calls int.__add__(3, 5). When you write 'hello' + ' world' Python calls str.__add__('hello', ' world'). Operator overloading lets you define what +, -, <, ==, len() and many other operations mean for your own classes — so that vector1 + vector2, account1 > account2 and if my_stack: all work naturally. Why operator overloading matters Without it, every class needs awkward method calls: The second version reads like mathematics — and Python lets you write it exactly like that. The magic […] - [Python inheritance exercises — master class hierarchies](https://sergiolearns.com/en/python-inheritance-exercises/): Python inheritance exercises are where object-oriented design stops being abstract and becomes a tool you reach for naturally. You’ve seen the theory and built three complete hierarchies. Now it’s time to design and implement your own — an animal system and a bank account hierarchy. As always: try to solve it yourself, use the hint if stuck for more than 10 minutes, and compare with the commented solution. Use pythontutor.com to step through and watch how super() and polymorphism work in practice. Python inheritance exercises — Basic to Intermediate Level Exercise 1 — Animal system Design and implement a complete animal […] - [Python inheritance practice — 3 real class hierarchies with polymorphism](https://sergiolearns.com/en/python-inheritance-practice/): In the previous article we covered Python inheritance theory. Now it’s time to build real hierarchies. In this article we implement three complete systems — an employee payroll system, a vehicle fleet and a product store — each one using inheritance, super(), method overriding and polymorphism in situations where they genuinely simplify the design. Python inheritance practice — Program 1: Employee payroll system This hierarchy models different types of employees with different salary calculation methods. It’s a perfect case for an abstract base class — every employee has a salary, but the way it’s calculated depends on the type. Output: Notice […] - [Inheritance and polymorphism in Python — super(), override and abstract classes](https://sergiolearns.com/en/python-inheritance/): Python Inheritance is the mechanism that lets one class reuse and extend the behaviour of another. If you’ve already built the Student, BankAccount and Product classes from the previous articles, you’ve seen that different classes can share a lot of structure — a Student and a Teacher are both Person objects, a SavingsAccount and a CurrentAccount are both BankAccount objects. Inheritance is how you express and exploit those relationships without repeating code. This article covers everything: the is-a relationship, super(), method overriding, isinstance(), multiple inheritance and abstract classes with @abstractmethod. The is-a relationship — when to use inheritance Inheritance models the […] - [Python classes exercises — master objects and encapsulation](https://sergiolearns.com/en/python-classes-exercises/): Python classes exercises are where object-oriented thinking becomes natural. You’ve seen the theory and built three complete programs. Now it’s time to design and implement classes on your own — a Student, a Vehicle and a Stack. As always: try to solve it yourself, use the hint if stuck for more than 10 minutes, and compare with the commented solution. Use pythontutor.com to step through your solution and watch the objects being created and modified in memory. Python classes exercises — Basic Level Exercise 1 — Student class Design and implement a Student class that models a university student. It must […] - [Python classes practice — 3 real programs with encapsulation and @property](https://sergiolearns.com/en/python-classes-practice/): In the previous article we covered Python classes theory. Now it’s time to write real programs. In this article we build three classes from scratch — a bank account, a book library and a product store. Each one introduces new concepts progressively and shows encapsulation and @property doing real work, not just theory. Python classes practice — Program 1: Bank account (step by step evolution) This program shows how a class evolves — starting minimal and adding features one by one. The evolution itself is the lesson. Version 1 — Minimal This works but has a problem: nothing prevents negative amounts […] - [Python classes — objects, encapsulation and magic methods from scratch](https://sergiolearns.com/en/python-classes/): Python classes are the tool that takes your programs from a collection of functions to a structured, reusable system. In FP1 you wrote code that ran from top to bottom. In FP2 you start modelling the real world — a student, a bank account, a product in a catalogue — as objects that have data and behaviour. This article covers everything: __init__, self, instance methods, private attributes, @property, __str__ and __repr__. What is a class and what is an object? A class is a blueprint — it defines the structure. An object is an instance created from that blueprint. The analogy […] - [Python exceptions exercises — write code that doesn't break](https://sergiolearns.com/en/python-exceptions-exercises/): Python exceptions exercises are where robust programming becomes second nature. You’ve seen the theory and built four complete programs. Now it’s time to solve challenges on your own — a password validator, a unit converter and a contact book with custom exceptions. As always: try to solve it yourself, use the hint if stuck for more than 10 minutes, and compare with the commented solution. Use pythontutor.com to step through your solution. Python exceptions exercises — Basic Level Exercise 1 — Robust password validator Write a program that asks for a password and validates it with these requirements, giving specific feedback […] - [Python exceptions practice — 4 real programs that don't break](https://sergiolearns.com/en/python-exceptions-practice/): In the previous article we covered Python exceptions theory. Now it’s time to write real programs that handle errors gracefully. In this article we build four programs from scratch — a data validator, a robust calculator, a file reader and a class with custom exceptions. Each one uses exceptions in a situation where they’re the natural, correct tool. Python exceptions practice — Program 1: Robust data validator This program asks for a name, age and grade, and keeps asking for each field until the user enters a valid value. It’s a perfect try/except use case — you can’t know in advance […] - [Exceptions in Python — try, except, raise and assert without complications](https://sergiolearns.com/en/python-exceptions/): Python exceptions are the mechanism that lets a program handle unexpected situations without crashing. In FP1 you learned to prevent errors with if/else. In FP2 you go a step further — catching them when they happen and raising them yourself when needed. This article covers everything: try/except, specific and generic exceptions, finally, raise and assert. What is an exception? When Python encounters a situation it can’t handle — dividing by zero, converting text that isn’t a number, accessing an index that doesn’t exist — it raises an exception and the program stops. An exception is an object that represents that error. […] - [Pointers in C exercises — master memory](https://sergiolearns.com/en/pointers-in-c-exercises/): Pointers in C exercises are where the mental model becomes instinct. You’ve seen the theory and built four complete programs. Now it’s time to solve challenges on your own in Fedora — copying arrays with pointers, counting and replacing elements, and a final challenge that implements a basic dynamic data structure. Set up your workspace: As always: try to solve it in gedit, compile with gcc, use the hint if stuck for more than 10 minutes, and compare with the commented solution. Pointers in C exercises — Basic Level Exercise 1 — Copy and compare arrays Write a C program with […] - [Pointers in C practice — 4 real programs to stop being afraid of them](https://sergiolearns.com/en/pointers-in-c-practice/): In the previous article we built the mental model for pointers in C. Now it’s time to write real programs and see them doing useful work. In this article we build four programs from scratch in gedit and compile them with gcc in Fedora — each one uses pointers in a situation where they’re the natural, correct tool. Set up your workspace: Pointers in C practice — Program 1: Variable swap The classic pointer program. Swapping two variables is impossible without pointers (or a temporary variable inside the function) because C passes everything by value. This program shows exactly why. Output: […] - [Pointers in C — memory addresses without the mystery](https://sergiolearns.com/en/pointers-in-c/): Pointers in C are the topic that intimidates most students before they’ve even seen them — and then surprises them with how logical they actually are once the mental model clicks. Python hides memory management completely. C exposes it directly. That’s not a flaw — it’s the feature that makes C both powerful and educational. Once you understand pointers you understand exactly what Python is doing behind the scenes when it passes objects between functions. This article builds the mental model from scratch, one concept at a time. What is a memory address? Every variable in your program is stored somewhere […] - [Loops in C exercises — master for, while and do…while](https://sergiolearns.com/en/loops-in-c-exercises/): Loops in C exercises are where for, while and do...while stop feeling like abstract concepts and become tools you reach for naturally. You’ve seen the theory and built three complete programs. Now it’s time to solve challenges on your own in Fedora — including Rock Paper Scissors, a number base converter, prime numbers and a final challenge that combines everything. Set up your workspace: As always: try to solve it in gedit, compile with gcc, use the hint if stuck for more than 10 minutes, and compare with the commented solution. Loops in C exercises — Basic Level Exercise 1 — […] - [Loops in C practice — 3 real programs with for, while and do…while](https://sergiolearns.com/en/loops-in-c-practice/): In the previous article we covered C loops theory. Now it’s time to write real programs. In this article we build three programs from scratch using gedit and gcc in Fedora — a number guessing game, a data validator and a series calculator. Each one uses the loop that genuinely makes the most sense for that problem, showing why the choice between for, while and do...while isn’t arbitrary. Set up your workspace: Loops in C practice — Program 1: Number guessing game with while This is the classic guessing game — the player has unlimited attempts to guess a secret number […] - [Loops in C — for, while and do…while without detours](https://sergiolearns.com/en/loops-in-c-for-while/): Loops in C for, while and do...while work with exactly the same logic as Python — the concept of repeating a block of code is identical. What changes is the syntax and one important addition: the do...while loop that Python doesn’t have. If you understood loops in Python, you’re 80% of the way there. This article covers the remaining 20% — the C-specific syntax, the differences that matter and the mistakes that cost the most time in IC2. The for loop in C In Python for always iterates over a sequence — a list, a range, a string. In C for […] - [Conditionals in C exercises — master if, else and switch](https://sergiolearns.com/en/conditionals-in-c-exercises/): Conditionals in C exercises are where the syntax stops feeling foreign. You’ve seen the theory and built three complete programs. Now it’s time to solve challenges on your own in Fedora — including a triangle classifier, a login system with attempts, and a final challenge that mixes everything. Set up your workspace: As always: try to solve it in gedit, compile with gcc, use the hint if stuck for more than 10 minutes, and compare with the commented solution. Conditionals in C exercises — Basic Level Exercise 1 — Triangle classifier Write a C program that reads the three sides of […] - [Conditionals in C practice — 3 real programs in gedit and Fedora](https://sergiolearns.com/en/conditionals-in-c-practice/): In the previous article we covered C conditionals theory. Now it’s time to write real programs. In this article we build three programs from scratch using gedit and gcc in Fedora — a grade classifier, a number guessing game and a calculator with a menu. Each one uses if/else if/else and switch in situations where the choice between them is intentional and clear. Set up your workspace: Conditionals in C practice — Program 1: Grade classifier This program reads a grade and classifies it — showing how if/else if handles ranges that switch can’t, and how to validate input before processing […] - [Conditionals in C — if, else if, else and switch without detours](https://sergiolearns.com/en/conditionals-in-c-if-else-switch/): Conditionals in C if else switch work with the same logic as Python — same concept, different syntax. If you understood if/elif/else in Python, you already understand how decisions work in C. What changes is the notation: curly braces instead of indentation, else if instead of elif, and a switch that works identically to the one you saw in Java. This article covers all of it with direct comparisons to Python and the mistakes that cost the most time in IC2. The if statement in C The basic structure: Three differences from Python: Parentheses around the condition — mandatory in C. […] - [Types and variables in C exercises — master printf, scanf and operators](https://sergiolearns.com/en/types-and-variables-in-c-exercises/): Types and variables in C exercises are where printf, scanf and the type system stop feeling foreign. You’ve seen the theory and built three complete programs. Now it’s time to solve challenges on your own in Fedora. In this article you’ll find four exercises across three levels — from a BMI calculator to geometric shapes, number bases and a final challenge that combines everything. As always: try to solve it in gedit, compile with gcc, use the hint if stuck for more than 10 minutes, and compare with the commented solution. Before starting: Types and variables in C exercises — Basic […] - [Types and variables in C practice — 3 real programs in gedit and Fedora](https://sergiolearns.com/en/types-and-variables-in-c-practice/): In the previous article we covered types and variables in C theory. Now it’s time to write real programs. In this article we build three programs from scratch using gedit and compile them with gcc in Fedora, the exact workflow you’ll use in every IC2 lab. Each program uses all the main types and shows the differences from Python in a real context. Open your Fedora terminal before starting. Setting up your workspace Create a separate file for each program as we go. Always open gedit with & to keep the terminal free. Types and variables in C practice — Program […] - [Types and variables in C — what changes from Python and what doesn't](https://sergiolearns.com/en/types-and-variables-in-c/): Types and variables in C are the first real shock when you move from Python to C in IC2. In Python you wrote x = 5 and Python figured everything out. In C you have to declare the type, the size and the format specifier for every variable, and if you get any of them wrong the compiler either refuses to compile or produces incorrect results silently. This article explains every difference clearly, with direct comparisons to Python so nothing is left without context. The fundamental difference — static vs dynamic typing In Python variables have no fixed type. You can […] - [C in Fedora — install gedit, compile with gcc and write your first program](https://sergiolearns.com/en/install-gedit-in-fedora-and-compile-with-gcc/): Setting up C in Fedora is the first practical step in IC2. Before you write a single line of C code you need two things: a text editor to write the code and a compiler to turn it into an executable program. In Fedora that means gedit and gcc. This article walks you through the complete setup and your first C program running in the terminal. What is gcc and why do you need it? In Python you ran programs directly, the interpreter read your .py file and executed it. C doesn’t work that way. C is a compiled language, before […] - [Basic Linux commands exercises — get comfortable in the terminal](https://sergiolearns.com/en/basic-linux-commands-exercises/): Basic Linux commands exercises are where the terminal stops feeling foreign. You’ve seen the theory and practiced navigating Fedora. Now it’s time to solve challenges on your own, with wildcards, paths, basic permissions and a final challenge that combines everything. These exercises are done directly in your Fedora terminal. Open it now and keep it open throughout the article. As always: try to solve it yourself, check the hint if you’re stuck for more than 10 minutes, and compare with the solution at the end. Before starting every exercise Getting lost is the most common frustration. Make pwd a reflex. Basic […] - [Basic Linux commands practice — navigate Fedora for real](https://sergiolearns.com/en/basic-linux-commands-practice/): In the previous article we covered the basic Linux commands you need for IC2. Now it’s time to actually use them. This article has three practical exercises you do directly in your Fedora terminal, no reading, just typing. By the end you’ll have built a complete working directory structure for IC2 and navigated your way around Fedora confidently. Open your Fedora terminal before starting. All exercises are done there. How this practice works Each exercise gives you a goal and a set of commands to try. Type every command yourself, don’t copy and paste. The muscle memory of typing commands is […] - [Basic Linux commands — the ones you use every day in IC2](https://sergiolearns.com/en/basic-linux-commands/): Basic Linux commands are the first practical skill you need in IC2. You’ve set up Fedora in VirtualBox and understood what the terminal is, now it’s time to actually use it. This article covers the commands you’ll type every single day: navigating directories, creating folders, copying and moving files, and the ones that can delete things permanently if you’re not careful. Everything here is tested in Fedora. Open your terminal and follow along, reading without practising won’t stick. How a terminal command works Before the commands themselves, it’s worth understanding the structure. Every command follows the same pattern: Options and arguments […] - [Linux for students — everything nobody explains before IC2](https://sergiolearns.com/en/linux-for-students/): Linux for students is one of those topics that GCID throws at you in IC2 without much preamble. One day you’re writing Python in VS Code on Windows, and the next you’re expected to navigate a terminal, manage files with commands and compile C programs in Fedora. This article is what I wish someone had given me before that first IC2 class, the conceptual foundation that makes everything else click. What is Linux, really? Most people think Linux is an operating system. That’s partially true but not the full picture. Linux is technically just the kernel, the core piece of software […] - [Python functions exercises — consolidate what you know](https://sergiolearns.com/en/python-functions-exercises/): Python functions exercises with solutions are where everything you’ve learned about functions gets tested for real. You’ve seen the theory and built three complete programs. Now it’s time to solve on your own. In this article you’ll find four exercises across three levels, from a grade converter to a mini bank and a dice game. Each one uses functions in a real, meaningful way, not just as syntax practice. As always: try to solve it, use the hint if you’ve been stuck for more than 10 minutes, and compare with the commented solution at the end. Use pythontutor.com to step through […] - [Python functions practice — 3 programs that show their real power](https://sergiolearns.com/en/python-functions-practice/): In the previous article we covered Python functions theory. Now it’s time to write real code. In this article we build three programs from scratch in VS Code where functions aren’t optional, they’re the difference between code that’s readable and maintainable and code that’s a mess. Each program is more modular than the last. Create a folder called functions_practice and a separate file for each program. Python functions practice — Program 1: Modular temperature converter This is a clean version of the temperature converter we built in the operators article, but now every conversion is its own function. Create temperature_converter.py: Output […] - [Python functions — stop repeating code once and for all](https://sergiolearns.com/en/python-functions/): Python functions are the tool that transforms messy code into organised, reusable code. Until now every program you wrote was a sequence of instructions that ran from top to bottom, once. Functions let you name a block of code and reuse it whenever you need it, without copying and pasting. This is one of the most important concepts in FP1 and the foundation of everything you’ll write from here on. What are Python functions? A function is a named block of code that performs a specific task and can be called as many times as needed from anywhere in the program. […] - [Python loops exercises — put them to the test](https://sergiolearns.com/en/python-loops-exercises/): Python loops exercises are where everything clicks. You’ve seen the theory and practised with real programs. Now it’s time to solve on your own. In this article you’ll find four exercises across three levels, from FizzBuzz (a classic that appears in real job interviews) to compound interest and prime numbers. As always: try to solve it, use the hint if you’ve been stuck for more than 10 minutes, and compare with the commented solution at the end. Use pythontutor.com to step through your solution and check what’s happening. How to use this article Read the exercise → try to solve it […] - [Python loops practice — 3 programs that finally make sense](https://sergiolearns.com/en/python-loops-practice/): In the previous article we covered Python loops theory. Now it’s time to write real code. In this article we build three programs from scratch in VS Code using for and while in situations where the choice between them isn’t arbitrary, each program uses the loop that genuinely makes more sense for that problem. Create a folder called loops_practice and a separate file for each program. Python loops practice — Program 1: Password validator This program asks for a password and keeps asking until the user enters one that meets all the requirements. It’s a perfect while use case — we […] - [Python loops — for and while without beating around the bush](https://sergiolearns.com/en/python-loops/): Python loops for and while give your code the ability to repeat itself. Without loops you’d have to write the same instruction a hundred times to do something a hundred times. With loops, three lines. It’s one of the most important concepts in FP1 and also one of the most confusing at first — especially knowing when to use for and when to use while, and understanding break, continue and nested loops. This article covers everything. What are loops? A loop is a structure that repeats a block of code multiple times. Just like conditionals, indentation and colons are mandatory in […] - [Python conditionals exercises — 4 solved with solutions and cheat sheet](https://sergiolearns.com/en/python-conditionals-exercises/): Python conditionals exercises with solutions are the best way to cement if, elif and else. You’ve seen the theory and practised with real programs. Now it’s time to solve on your own. In this article you’ll find four exercises across three levels of difficulty, with special attention to the mistake of confusing and with or — one of the trickiest in FP1. As always: try to solve it, use the hint if you’ve been stuck for more than 10 minutes, and compare with the commented solution at the end. You can also step through the code in pythontutor.com to see it […] - [Python conditionals practice — 3 real programs in VS Code](https://sergiolearns.com/en/python-conditionals-practice/): In the previous article we covered Python conditionals theory. Now it’s time to write real code. In this article we build three programs from scratch in VS Code using if, elif and else in real situations: a registration form validator, a customer loyalty discount system and a grade classifier with a menu. Each program starts simple and gains complexity, just like the exercises in FP1. Create a folder called conditionals_practice and a separate file for each program. Python conditionals practice — Program 1: Registration form validator This program simulates the basic validation that any website does when you register. Create the […] - [Python conditionals — if, elif and else explained from scratch](https://sergiolearns.com/en/python-conditionals/): Python conditionals if elif else are the first tool that gives your code intelligence. Until now your programs executed every line in order, top to bottom, making no decisions. With conditionals you can make Python execute certain instructions or others depending on whether a condition is met. It’s the leap from «program that calculates» to «program that decides». What is a conditional? A conditional is a structure that tells Python: «if this condition is met, do this, if not, do something else». In real life we make conditional decisions constantly: if it’s raining, take an umbrella; if it’s not raining, don’t. […] - [Python debugging — how to find errors without losing your mind](https://sergiolearns.com/en/python-debugging/): Python debugging is one of the most important skills nobody teaches you directly in first year. You know how to write code, but when something goes wrong, and it always goes wrong, you don’t know where to start looking. In this article I’ll explain how to debug Python using the three tools I use most: Thonny, Python Tutor and the VS Code debugger. We’ll also cover the three types of errors that appear most in FP1 and how to identify them quickly. What is debugging? Debugging (from the English word «bug») is the process of finding and fixing errors in your […] - [Python operators exercises — 5 solved with solutions and cheat sheet](https://sergiolearns.com/en/python-operators-exercises/): Python operators exercises with real context are the best way to cement what you learned in theory and practice. In this article you’ll find five exercises across three levels: basic, intermediate and final challenge, with special focus on % and // the operators that confuse the most. As always: try to solve it, use the hint if you’ve been stuck for more than 10 minutes, and compare with the commented solution at the end. You can use pythontutor.com to deepen your understanding step by step. How to use this article Read the exercise → try to solve it in VS Code […] - [Python operators practice — 3 real programs in VS Code](https://sergiolearns.com/en/python-operators-practice/): In the previous article we covered Python operators theory. Now it’s time to write real code. In this article we build three programs from scratch in VS Code using all the operators you learned: a unit converter, a discount calculator and a full calculator with a menu. Each program goes from simpler to more complete, just like the exercises in class. Before starting make sure you have VS Code configured. Create a new folder called operators_practice and inside it create a separate file for each program. Practising Python operators with real code is the best way to consolidate them. I also […] - [Python operators — complete guide with the mistakes everyone makes](https://sergiolearns.com/en/python-operators/): If you’re already comfortable with variables and data types, the next natural step is Python operators. They’re the tools that let you perform calculations, compare values and make decisions in your code. In this article we cover every type of Python operators you need in your first year, with the three mistakes I saw most often in class explained in detail. What are Python operators? An operator is a symbol that tells Python what operation to perform with one or more values. For example the + in 3 + 5 is an operator that tells Python to add those two values […] - [Shared folder between Windows and Fedora in VirtualBox — complete guide](https://sergiolearns.com/en/shared-folder-windows-and-fedora-virtualbox/): Once you have Fedora running in VirtualBox, the next thing you need is to be able to pass files between Windows and Fedora without complications. In IC2 this is essential: you write code in Fedora but you probably want to have it backed up in Windows too, or submit it through the university platform. In this guide, we will set up a shared folder Windows and Fedora VirtualBox: a step-by-step setup that includes the Fedora 43 Guest Additions install and solutions to the most common errors. Fair warning from the start: installing Guest Additions on Fedora 43 is not as straightforward […] - [How to install Fedora on VirtualBox — step by step guide for students](https://sergiolearns.com/en/install-fedora-on-virtualbox/): To install Fedora on VirtualBox was one of the first things we were asked to do in our Computer Engineering II course (IC2) at ULPGC. It sounds simple but there are several steps where it’s easy to get lost if nobody guides you. This guide walks you through every decision so you understand what you’re doing and why, not just what buttons to click. If you don’t have VirtualBox installed yet, download it first from virtualbox.org along with the Extension Pack. . What is VirtualBox and why use it? VirtualBox is a program that lets you run one operating system inside […] - [What you need to know about computing before you start programming](https://sergiolearns.com/en/basic-computing-before-programming/): When I started my Data Science and Engineering degree at ULPGC, I thought programming was just writing code. But the first few weeks I realised there are a lot of basic computing concepts that everyone assumes you already know, and that nobody actually explains directly. In this article I’ll tell you exactly what you need to have clear before writing your first line of Python. No unnecessary jargon, just what really matters. Hardware vs Software — the difference that always confuses The first thing you need to understand is the difference between hardware and software because you’ll hear both terms constantly […] - [Variables and data types in Python — exercises with solutions and cheat sheet](https://sergiolearns.com/en/variables-and-data-types-in-python-exercises/): You’ve seen the theory and practised with real code. Now it’s time for the moment of truth: solving exercises on your own. In this article you’ll find intermediate-level exercises on variables and data types in Python, a final challenge exercise that mixes everything from the topic, and a complete cheat sheet to keep handy. The method is simple: try to solve it, use the hint if you get stuck, and compare with the commented solution at the end. You can use pythontutor.com to visualise the execution step by step if something isn’t clicking. Before starting, review the theory or the practice […] - [Variables and data types in Python — hands-on practice with VS Code](https://sergiolearns.com/en/variables-and-data-types-in-python-practice/): In the previous article we covered the theory behind variables and data types in Python. Now it’s time to put variables and data types in Python practice with real code. We’ll build two programs from scratch in VS Code: a grade average calculator and a BMI calculator, simple but using everything you need to know in real situations. Before starting, make sure you have VS Code set up with Python. If you haven’t done that yet, here’s the guide. How we’ll work Open VS Code, create a folder called variables_practice and inside it create a new file called grade_average.py. Keeping your […] - [Variables and data types in Python — why Python thinks differently](https://sergiolearns.com/en/variables-and-data-types-in-python/): Variables and data types in Python were one of the first things that confused me when I started my Data Science and Engineering degree. In Python you just write x = 5 and you have a variable. No type declaration. No telling the computer what kind of value it is. Coming from zero programming experience, that felt like magic. In this article I’ll explain what’s actually happening behind the scenes, which data types you’ll use constantly, and the two mistakes with types that absolutely everyone makes at the beginning. What is a variable? A variable is simply a name you give […] - [How to install and set up VS Code for Python — the extensions I use at university](https://sergiolearns.com/en/configure-vs-code-for-python/): Configuring VS Code for Python correctly is the first thing you should do before writing a single line of code. When I decided to practice on my own and start building my own programs, it took me days to get it properly configured, nobody told me which extensions to install or how to set it up to work comfortably. In this article I’ll tell you exactly what I use, no fluff. What is VS Code and why don’t we just use Python’s IDLE? Python comes with its own editor called IDLE, but it’s basic and limited. VS Code is a free, […] - [How to install Python on Windows and write your first program](https://sergiolearns.com/en/install-python-on-windows/): When I started my Data Science and Engineering degree at ULPGC, the first programming subject I took was Fundamentals of Programming I (FP1). During my first year, I never actually had to install Python on Windows. The university provided an online environment called Aulaga where we coded directly from the browser using VPL. But when you want to practice on your own, outside the virtual campus, you really should have it on your computer so you don’t depend on having an internet connection. It sounds simple, but there are small details nobody warns you about that can cause problems. In this […] ## Pages - [Contact](https://sergiolearns.com/en/contact/): Found a mistake in an article, have a question or want to suggest a topic? Write to me, I read every email. sergio@sergiolearns.com What you can write to me about I usually reply within a few days. During exam season it may take a bit longer, because I’m studying too. Before you write SergioLearns is a personal project and is not an official ULPGC website. For any official matter about a course (grades, dates, assessment), contact your teaching staff or the university’s channels. Your data will only be used to reply to you, as explained in the privacy policy. - [Privacy policy](https://sergiolearns.com/en/privacy-policy/): Last updated: 24 September 2026 On this page I explain what personal data is collected on SergioLearns, what it is used for and what your rights are, in accordance with the General Data Protection Regulation (GDPR) and Spanish Organic Law 3/2018 (LOPDGDD). Data controller What data is collected and why Comments. If you comment on an article, the name, email and website you provide are stored, together with your IP address and browser details, in order to publish the comment, reply to you and prevent spam. Your email is never published. An anonymised code created from your email is sent to […] - [Cookie policy](https://sergiolearns.com/en/cookie-policy/): Last updated: 24 September 2026 What cookies are Cookies are small files that a website stores in your browser to remember information about your visit. Some are essential for the website to work; others are used to measure usage or show advertising, and those are only set if you give your permission. Which cookies SergioLearns uses Technical (always active). They are necessary for the website to work and do not require consent: Analytics (only with your permission). Google Analytics uses cookies such as _ga to count visits and understand, in aggregate, how the website is used. They can last up to […] - [Legal notice](https://sergiolearns.com/en/legal-notice/): Last updated: 24 September 2026 Website owner In accordance with Spanish Law 34/2002 on Information Society Services and Electronic Commerce (LSSI-CE), these are the details of the owner of sergiolearns.com: What SergioLearns is SergioLearns is a personal educational website where I explain programming, systems and other subjects from the Data Science and Engineering degree, with theory, solved programs and exercises. SergioLearns is not an official website of the University of Las Palmas de Gran Canaria (ULPGC) and is not affiliated with it. References to courses such as FP1, FP2 or IC2 are there to guide students. For any official matter about […] - [Java — Exercises](https://sergiolearns.com/en/java-exercises/): All Java exercises with commented solutions and cheat sheets. Syntax, arrays, strings, classes and OOP — three difficulty levels per topic with full solutions. - [Java — Practice](https://sergiolearns.com/en/java-practice/): All Java practice articles with real programs. Syntax, arrays, strings, classes and OOP applied to working code with direct comparisons to Python equivalents. - [Java — Theory](https://sergiolearns.com/en/java-theory/): All Java theory articles in order. Syntax, variables, control flow, loops, methods, arrays, strings, regular expressions, classes, inheritance and exceptions — explained for developers who already know Python. - [Linux and C — Exercises](https://sergiolearns.com/en/linux-and-c-exercises/): All Linux and C exercises with commented solutions and cheat sheets. Terminal commands and C programming — variables, pointers, loops and functions with three difficulty levels per topic. - [Linux and C — Practice](https://sergiolearns.com/en/linux-and-c-practice/): All Linux and C practice articles with real programs. Terminal commands applied to real tasks and C programs using variables, conditionals, loops, pointers and functions with working code. - [Linux and C — Theory](https://sergiolearns.com/en/linux-and-c-theory/): All Linux and C theory articles in order. Linux terminal, basic commands, C variables, conditionals, loops, pointers and functions explained from scratch with comparisons to Python. - [Intermediate Python — Exercises](https://sergiolearns.com/en/intermediate-python-exercises/): All Intermediate Python exercises with commented solutions and cheat sheets. Classes, inheritance, iterators, unittest testing and LinkedList — three difficulty levels per topic. - [Intermediate Python — Practice](https://sergiolearns.com/en/intermediate-python-practice/): All Intermediate Python practice articles with real programs. Classes, inheritance, iterators, generators, unittest testing and LinkedList applied to real examples you can run and modify. - [Intermediate Python — Theory](https://sergiolearns.com/en/intermediate-python-theory/): All Intermediate Python theory articles in order. Exceptions, classes, inheritance, operator overloading, iterators, generators, testing with unittest and linked structures. If you come from Basic Python you already have the foundation to start here. - [Basic Python — Exercises](https://sergiolearns.com/en/basic-python-exercises/): All Basic Python exercises with commented solutions. Three difficulty levels per topic — try to solve them yourself before checking the solution. Variables, operators, conditionals, loops and functions. - [Basic Python — Practice](https://sergiolearns.com/en/basic-python-practice/): All Basic Python practice articles in order. Real programs using variables, operators, conditionals, loops and functions. Each article builds on the theory and adds working code you can run and modify. - [Basic Python — Theory](https://sergiolearns.com/en/basic-python-theory/): All Basic Python theory articles in order. Variables, operators, conditionals, loops and functions explained from scratch with real examples and direct comparisons with other languages. If you’re starting with Python, start here. - [About Me](https://sergiolearns.com/en/about-me/): Hi, I’m Sergio I am a second-year Data Science and Engineering student at ULPGC, and I write SergioLearns to explain my degree the way I wish it had been explained to me. Start learning Write to me Who I am I was born in Gran Canaria to Colombian parents, and I grew up between two worlds that complement each other. I have always liked maths and computing. I was about to study Telecommunications. What changed my mind was seeing the impact artificial intelligence was having in such a short time, and the uncertainty it created about the jobs of the future. […] - [Resources](https://sergiolearns.com/en/resources/): These are the tools and resources I actually use every day as a GCID student. No filler: if it’s here, it’s because I use it. Cheat sheets Every cheat sheet on the site in one place. Each one takes you straight to the final summary of its exercises article, perfect for revising before an exam. For coding The setup I have installed. If you need help configuring it, the step-by-step guides are in Tools. PythonThe language of FP1 and most of the degree. Free, with a Windows installer.python.org VS CodeThe editor I use for Python and C. Lightweight, with extensions for […] - [Blog](https://sergiolearns.com/en/articles/): All articles from Sergio Learns in one place. Python, Java, Linux and C — theory, practice and exercises sorted by topic. - [Home](https://sergiolearns.com/en/inicio-english/): What you study at university, explained by someone who just went through it. I’m Sergio, a Data Science and Engineering student at ULPGC. Here I explain Python, C, Java and Linux step by step, with solved programs and exercises with solutions. sergio@learns:~$ Search SergioLearns python loops Search Start from scratch Browse by course Where do you want to start? Start programming Python from scratch: variables, loops and functions, assuming nothing. See solved programs Complete, commented code to see every concept actually working. Test myself Exercises by level, with hints and the solution explained at the end. Set up my environment Install […] ## Optional - [Agent (MCP protocol)](websites-agents.hostinger.com/sergiolearns.com/mcp) [comment]: # (Generated by Hostinger Tools Plugin)