Write code that will calculate number of vowels in a string

Assignment Help Python Programming
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).

Reference no: EM132390082

Questions Cloud

What clinical problem or issue the organization is facing : During your practicum, determine what clinical problem or issue the organization is facing. Discuss two implications for nursing. (First problem) Nursing short
What is the main issue for your organization : What is the main issue for your organization in addressing a solution to evidence-based nursing practice? Discuss what might be the first step in addressing.
Describe the significance and relevance of the problem : Describe the significance and relevance of the problem. What is the appropriate communication level for the target audience's educational experience in order.
Explain the five stages of group development : Based on what you have learned so far this week, create a PowerPoint presentation (minimum 12 slides) with detailed notes for each slide that addresses.
Write code that will calculate number of vowels in a string : 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.
Create and implement a policy that addresses social prolem : As an astute social worker and professional policy advocate, once you have selected and identified a social problem, you begin the process of creating.
Identifies transformational and charismatic leader behaviors : Identifies transformational and charismatic leader behaviors. In your opinion, which of the behavioral components does Ms. Burns exemplify
Develop a Graphical User Interface : You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the CityLodge rental room management program
Senior management for future strategic planning : Explain an approach that you would present to senior management for future strategic planning.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd