Reference no: EM132390082
(a) Total number of vowel occurrences in a string
To answer this question, you need to write code that will calculate the number of vowels in a string. You should count each occurrence of any vowel and count vowels both in upper and lower case, so a vowel is any of the letters in the string: aeiouAEIOU. (Do not count "y", though it may be used as a vowel, e.g. in "my".)
Examples
|
INPUT
|
OUPUT
|
yyyyk z
|
0
|
A cat sat on a mat
|
6
|
Abracadabra
|
5
|
Eutopia
|
5
|
(b) Number of different vowels in a string
To answer this question you need to write code that will determine the number of different vowels in a string input by the user. By "different vowels" we mean that if the same vowel occurs more than once it is only counted once. Moreover, small and captial versions of the same letter do NOT count as different vowels. Thus, the number given as the answer will always be from 0 to S (inclusive).
Examples
|
INPUT
|
OUPUT
|
yyyyk z
|
0
|
A cat sat on a mat
|
2
|
Abracadabra
|
1
|
Eutopia
|
5
|
(c) Anonymise a string
For certain purposes, e.g. reviewing academic articles, it may be required that names in documents be anonymised to hide the identiy of the person referred to. It may also be required to preserve formatting, so that the space taken up by the anonymised name is approximately the same as the original name.
A simple way to do this is to replace all the letters with Xs. Your program should carry out this operation. More specifically you should transform the input string by replacing each capital letter by 'X' and each lower case letter by 'x'.
Examples
|
INPUT
|
OUPUT
|
Brandon Bennett
|
Xxxxxxx Xxxxxxx
|
Hello!
|
Xxxxx!
|
Alfred E. Neuman
|
Xxxxxx X. Xxxxxx
|
Password Strength
An institution uses the following rules to classify the strength of passwords:
• A string is a WEAK password if it is less than 8 characters long.
• A string is a STRONG password if:
o it contains at least 11 characters
o AND it contains at least 1 lower case letter
o AND it contains at least 1 capital letter
o AND it contains at least 1 numerical digit.
• A string is a MEDIUM password if it is NOT a WEAK password AND is NOT a STRONG password.
You need to write code that will take input of a string from the keybord and will print the strength of that string as a password, according to the rules given above. So it should output one of the strings STRONG, WEAK or MEDIUM
Examples:
Examples
|
INPUT
|
OUPUT
|
hello
|
WEAK
|
7Ki ngs8a1 1 9R i es
|
STRONG
|
brandon123
|
MEDIUM
|
Megabyte Energy Bars Question
The SnackShack convenience store sells Megabyte energy bars according to the following pricing rules:
• Single Megabyte bar: £1.25
• Megabyte Sixpack (6 bars): £5
• 10% Discount given on all orders of £20 or more!
To answer this question, write a Python program that takes one input, which is the number of Megabyte bars a customer wants to buy, and gives 1 output which is the total cost in pounds of buying that number of Megabyte bars.
Examples
Num Bars (input)
|
Cost in £s (output)
|
Cost Breakdown
|
3
|
3.75
|
3 single bars
|
12
|
10
|
2 six packs
|
15
|
13.75
|
2 sixpacks and 3 single bars
|
26
|
20.25
|
4 sixpacks, 2 singles (22.50), 10% discount (-2.25).
|