Python Programming Immersion
Week 2 Assignment
1. Write a small program to ask for a name and an age.
When both values have been entered, check if the person is the
right age to go on an 18-30 holiday (they must be over 18 and
under 31).
If they are, welcome them to the holiday, otherwise print a
(polite) message refusing them entry.
2. Create a program that takes some text and returns a list of
all the characters in the text that are not vowels, sorted in
alphabetical order.
You can either enter the text from the keyboard or initialise a
string variable with the string.
3. Create a program, that takes one integer argument
representing a number of minutes. The program will convert
the argument to the corresponding number of seconds, and
print that value out.
Eg. If user enter 5, it should return the corresponding value in
seconds which is 300
4. Write a program to print times tables. If you enter a number,
it should generate the table fr that number. Eg. If user enter 2,
it should generate
2x1 = 2
2x2 = 4
…
Up to 2 x 12 = 24
5. Write a program to create a simple calculator
Users should be requested to enter the first number, second
number and operator
eg. first number = 2
Sencond number = 4
Operator = *
This should print(2x4= 8)
6. Create a program, that takes in one numeric argument
representing a Celsius value. Then, print out the corresponding
Fahrenheit value to two decimals in the form:
The temperature is x degrees Fahrenheit.
Where x is the calculated Fahrenheit value
Hint: °F = (°C × 9/5) + 32
7. Create a program, [Link], that has a function that takes a
number and prints the number of digits in the number. It
should work for numbers with decimals, too.
8. Create a program, [Link], that has a function that takes
one string argument and prints a sentence indicating the
longest word in that string. If there is more than one word print
only the first. Your print statement should read:
“The longest word is x”
Where x = the longest word. The word should be all lowercase.
9. Create a program, that has a function that takes one string
argument and prints a sentence indicating if the text is a
palindrome. The function should consider only the
alphanumeric characters in the string, and not depend on
capitalization, punctuation, or whitespace.
If your string is a palindrome it should print:
It is a palindrome!
If it is not a palindrome, it should print:
It is not a palindrome!