Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a new Python project in PyCharm. 2. One file,BalancedAB.py will contain the main function described in the next item. 3. Define a function

1. Create a new Python project in PyCharm.

2. One file,BalancedAB.py will contain the main function described in the next item.

3. Define a function BalancedAB(string st) which is a Boolean function that returns True if for every A character in a string of uppercase letters and spaces, there exists a B character to be found somewhere later in the string.

4. Hint: the method rindex() in Python returns the last index where a certain substring str\ is found, or raises an exception if no such index exists: str.rindex(str, beg=0 end=len(string))

(a) str : This specifies the string to be searched.

(b) beg : This is the starting index, by default its 0.

(c) len : This is ending index, by default its equal to the length of the string.

5. In the second file, Test BalancedAB.py , you will define your own class derived from unittest.TestCase. Then, you need to fill it with functions that start with test . Finally, you need to run the tests by placing unittest.main() in your file, usually at the bottom.

6. Create nine test cases for each of the following possible outcomes. The name of each test method should be the string TestBalancedAB, followed by an integer digit:

1 BalancedAB(AAZZBB) true

2 BalancedAB(AAAXXXXYB) true

3 BalancedAB(BBYYYXXXAXX) false

4 BalancedAB() true

5 BalancedAB(XXXXXYYYYZZZZB) true

6 BalancedAB( XXXXXYYYYZZZZ) true

7 BalancedAB(XXXX XYYYY ZZZZB) true

8 BalancedAB(YYYBABYYYXXXAXX) false

9 BalancedAB(ABABABA) false

7. Make any necessary corrections to the class under test until all unit tests pass.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions

Question

Describe the Indian constitution and political system.

Answered: 1 week ago

Question

Explain in detail the developing and developed economy of India

Answered: 1 week ago

Question

Problem: Evaluate the integral: I = X 52+7 - 1)(x+2) dx

Answered: 1 week ago

Question

What is gravity?

Answered: 1 week ago

Question

What is the Big Bang Theory?

Answered: 1 week ago