Félix Albertos Marco

Trivial exercise in Python

28/11/2023

Home/blog/2023>

Trivial exercise in Python

[programming] [python] [teaching]

Teaching is a never ending journey. Indeed, keeping up to date on methodologies, technologies, …, specially in a computer science curricula, is challenging if not impossible!

This year I’m working on introducing new contents into my subjects, as always. It is a never ending process1. It is a process of analyzing the state of the art, the “up to date”, “emerging”, “on the edge” topics that will help our students to build a competitive cv.

Programming is one of the topics that most of our students are interested on. Me too. It was one of the core things that push me to make a career in computer science. And I’ve learn, and work, in many languages, frameworks, platforms and paradigms. But I’ve always been a “Web oriented developer”. As I always say when some one talks me about making an application: Let’s make a Web Application!

But this time, I’ve taken some time to learn something I’ve been always interested on, Python. I’ve never have an excuse to learn it, neither the need. But finally, I’ve taken some time and learn the core basics. As a result, here is a trivial exercise in Python that I’ve previously developed in many other languages. In fact, I’ve also proposed this exercise to my students, or at least part of it: let’s make a triangle, or a square, or why not, a star. It is one of the most basic exercise to begin with with any language. It forces you to put in practice some of the basic concepts related with input/output, structure controls and functions (or modules).

As follows, it is depicted an execution of the program:

Introduce la anchura del dibujo
9
Introduce tipo de dibujo: Cuadrado (C), Triángulo (T), Estrella (S)
s
        * 
      * * * 
    * * * * * 
  * * * * * * * 
* * * * * * * * * 
  * * * * * * * 
    * * * * * 
      * * * 
        *