Topics: Iteration, Simple Programs: guess and check, binary, fractions
Lecture Notes
Lecture 4: Loops over Strings, Guess-and-Check, Binary
Readings
Ch 3.1, 3.3
Finger Exercise Lecture 4
Assume you are given a positive integer variable named N
. Write a piece of Python code that finds the cube root of N
. The code prints the cube root if N
is a perfect cube or it prints error
if N
is not a perfect cube. Hint: use a loop that increments a counter—you decide when the counter should stop.