Simple types and strings (1)

You have to program several functions. In each case, few lines of code are enough.

  1. Write a function @drawH(n)@ that given an odd integer n3n\ge 3 prints a letter H of size nn formed with symbol . Follow the pattern of the example below.

  2. Write a function @area_circle(r)@ that given a float number r0r\ge 0 returns, rounded to the hundredth, the area of the circle of radius rr. Use the pi constant defined in the math module.

  3. Write a function @slow_pi_aprox(n)@ that given a non negative integer nn computes 4k=0n(1)k2k+14\sum_{k = 0}^n \frac{(-1)^k}{2k + 1} rounded to the hundredth.

  4. Write a function @is_univariate_number(n)@ that given a non negative integer returns a boolean pointing out whether nn is represented using only one digit. For instance 2222222222 is univariate but 2232222322 is not.

  5. Write a boolean function @is_univariate_word(s)@ that given an string ss returns True if and only if ss is formed using only one letter. For instance word xxXxXXx is univariate but xxXxy is not. We assume ss is non empty and all characters of ss are letters.

Scoring

Every function counts 20 points.

Sample session

Problem information

Author: Jorge Castro

Generation: 2026-01-25T11:24:03.674Z

© Jutge.org, 2006–2026.
https://jutge.org