Exercises: Series I¶
A so-called perfect number is an integer that is the sum of all its divisors (except itself, of course).
For example, 6 is a perfect number since 6 can be divided by 1, 2, and 3, and 6=1+2+3
- write a series of statements that computes the sum of a list of integer numbers
- write a series of statements that create, from a given integer, the list of its divisors
- write a series of statements that evaluates (True or False) if an integer is a perfect number
- find all perfect numbers < 10000
random module, write a Python script that creates a password using random characters (digit, letter, and non-letter/digit like
square root (integer ensemble)¶
Write a python script that computes the integer square root of a given integer n, i.e., the highest number for which its square is lower than n.
square_root(9) = 3 square_root(10) = 3 square_root(15) = 3 square_root(16) = 4
Write a python script that converts a string of "0" and "1" into a decimal number.
binary("0") = 0 binary("1") = 1 binary("01") = 2 binary("001") = 4 binary("101001") = 37
Rewrite all your previous scripts using functions
Rewrite all your previous scripts using classes