Warm-up exercises¶
1. Print Hello world!
In [ ]:
2. Find the squares of the numbers from 1 to 10.
In [ ]:
3. Find all odd positive integers less than 20.
In [ ]:
4. Do the FizzBuzz problem in Python.
"Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”."
In [ ]:
5. Find all unique Pythagorean triples \((a, b, c)\) such that (\(a^2 + b^2 = c^2)\) for \(c < 50\). Only use positive integers.
In [ ]:
6. Working with strings
Count the number of times ‘Mary’ occurs in the nursery rhyme
Replace Mary with Margie
Find all the words that end a line. You should get a list that begins with
lamband ends withreply. The words should not include punctuation.
In [1]:
s = """Mary had a little lamb,
whose fleece was white as snow.
And everywhere that Mary went,
the lamb was sure to go.
It followed her to school one day
which was against the rules.
It made the children laugh and play,
to see a lamb at school.
And so the teacher turned it out,
but still it lingered near,
And waited patiently about,
till Mary did appear.
“Why does the lamb love Mary so?"
the eager children cry.
“Why, Mary loves the lamb, you know."
the teacher did reply"""
In [ ]:
In [ ]:
In [ ]: