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 n ≥ 3 prints a
    letter H of size n formed with symbol . Follow the pattern of the
    example below.

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

3.  Write a function @slow_pi_aprox(n)@ that given a non negative
    integer n computes $4\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 n is represented
    using only one digit. For instance 22222 is univariate but 22322 is
    not.

5.  Write a boolean function @is_univariate_word(s)@ that given an
    string s returns True if and only if s is formed using only one
    letter. For instance word xxXxXXx is univariate but xxXxy is not. We
    assume s is non empty and all characters of s 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
