Download Python Exercises Two

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Chatterbox
There is a woman who catches the same bus as you on your way to school every morning. She tends to talk
on her mobile phone a lot. You tend to be very sleepy in the morning, so decide to keep track of how much
she talks as a way of staying awake.
Write a Python program to read in two sentences that the woman last spoke. Your
program should then print out the length of the two combined sentences. For
example:
Enter the first: Like, I know, right?
Enter the second: Tell me about it!
She spoke 37 characters
Here is another example:
Enter the first: Oh, this is my stop.
Enter the second: I'll talk to you later!
She spoke 43 characters
Googol
A googol is not a search engine; it is a very large number! It is the number "1" followed by a hundred zeros,
or 10100.
Python is special in programming languages in that it can easily represent this number, whereas it is too
large for many other languages to understand.
Write a program that tells you how many of some other number you can fit inside a googol. For example:
Enter a number to fit inside a googol:
9997123458009008009009999123499786745
This fits 1000287736967846236140060080848205377824228835518895900026795380
times!
Duck, Duck, Goose!
Most of you probably played Duck, Duck, Goose at school when you were younger.
Write a program that prints out what the person who is "in" says depending on how far around the circle the
person who they have chosen to be the goose is sitting. For example:
Which number is the goose? 5
duck, duck, duck, duck, goose!
And another example:
Which number is the goose? 1
goose!
Costa Concordia
At the start of 2012, the cruise ship Costa Concordia sank after running into a coral reef off the Italian coast.
The cruise ship was not meant to come closer than 100m off the shore. Unfortunately, the captain set the
ship in closer than 100m, and it hit the underwater reef. Your task is to prevent this disaster!
Write a program to read in the distance the ship is from shore. If the distance from shore is less than 100m,
print outToo close!, otherwise print Safe..
For example:
Enter the distance (in metres): 102
Safe.
And another example:
Enter the distance (in metres): 98
Too close!
Sequel Rating
You love a movie, but is it worth watching its sequel? If the rating it gets online is better or the same, then
you might like to watch it.
You should write a Python program to ask the user for two ratings; the rating of the original movie and the
rating of the sequel. Your program should then announce either that The sequel is worth
it! or Give it a miss..
If the rating of the sequel is less than that of the original, your program should output Give it a miss..
Otherwise, it should output The sequel is worth it!.
For example:
Enter the original rating: 90
Enter the sequel rating: 100
The sequel is worth it!
Here is another example:
Enter the original rating: 50
Enter the sequel rating: 10
Give it a miss.