Create a program to produce a business speak phrase, Python Programming

Assignment Help:

The goal of this exercise is to write a \business phrase" generator, which each time it is called produces lines of business speak, such as:

It's time that we became uber-efficient with our interactive policy hardware At base level, this just comes down to holistic relative consulting Only geeks stuck in the 90s still go for functional modular capability We need to get on-message about our 'Outside the box' modular matrix approaches The idea is very similar to the \Eureka Machine" discussed in lectures: to produce a business speak phrase, your program should randomly select and print a phrase from each of four lists in turn.

These lists are stored in files named beginning.txt, adjective.txt, inflate.txt and noun.txt, which can be downloaded from the resources website;1 a business speak phrase is constructed by selecting a phrase from each of these in the order beginning.txt, adjective.txt, inflate.txt and noun.txt.

Write a program that will read the required words and phrases from the _les and print _ve business speak phrases. The program should be organised so that it can easily be changed to print any number of phrases.

You should submit:

1. A brief explanation of how your program is structured and why you have structured it that way.

2. An example of the output of your program, cut-and-pasted from the command prompt or a screenshot.

3. A hardcopy of the program.

4. Your program in a file business.py.

Hints:

1. You may use the dice.choose function discussed in lectures.

2. As before, you can read all the lines in a file with lines = open ('myfile .txt ', 'r'). readlines () myfile.txt must be in the same directory as your program. Remember that each line will have a newline character at the end.

3. You can remove the newline and any other whitespace from a string using strip: for example:

>>> s = ' string with spaces at the beginning and end \n'

>>> s ' string with spaces at the beginning and end \n'

>>> stripped = s. strip ()

>>> stripped 'string with spaces at the beginning and end '

Shuffling. One way to shuffle a deck of cards or a list is to repeatedly choose a pair of cards/items at random and to swap their positions in the deck/list. Write a function shuffle(L, nswaps) which shuffles the list L in-place using this method, swapping pairs nswaps times. Write a test function that uses assert statements to check that none of the elements of a list of integers are lost and none are gained by the shuffling.

How many swaps are needed to properly shuffle the list? Clearly one or two swaps don't make much difference, but for a small list there's not much point in doing thousands of swaps. To answer this question we can define the quality of a shuffle as the fraction of times the second element of two adjacent elements is larger than the first. Thus the sorted list [0, 1, 2, 3, 4, 5, 6] has a quality 6=6 = 1 because every element is greater than the previous one, whereas the list [1, 4, 2, 3, 6, 5, 0] has a quality 3=6 = 0:5 because the pairs (1; 4); (2; 3); (3; 6) have the second element greater than the first, but the other pairs (4; 2); (6; 5); (5; 0) do not. A well-shuffled list will have a quality close to 0.5.

Write a function quality(L) that evaluates how well the list L is shuffled. Then write a function average quality(nswaps)that uses these functions to evaluate the average quality of a shuffle of the list of integers range(50), using nswaps swaps. To get reliable answers you will need to take the average over, say, 30 different shuffles. Finally, write a program that prints out the average quality of a shuffle of a list of length 50 using 5, 10, 15, . . . , 200 swaps.

The code should be in a file named shuffle.py. Organise the code so that the functions can be imported into other programs and the average qualities are printed out when the module is run as python shuffle.py. How many swaps do you think is a good number for a list of length 50? How many for a list of length N?

You should submit:

_ A paper copy of the code. (Via BART.)

_ A paper copy of the output of a run of your program, showing the qualities for different

numbers of swaps. (Via BART.)

_ A hard copy of your code. (Via BART.)

_ An electronic copy of your program in a _le named shuffle.py. (Electronic submission.)

The stylised picture of a fern (above) is an example of a fractal, an object with non-integer dimension, similar to the Koch curve from workshops. The dimension of this one is di_cult to calculate, but is something between a line, with dimension 1, and a plane, with dimension 2. Fractals are extensively used in describing and modelling natural objects with structure on many length scales, such as the coastline of Great Britain, the shape of clouds, the distribution of stars in the universe, the structure of intestinal walls, plants and so on. They are also used in computer graphics to make realistic models of terrain and natural scenery. The classic reference for fractals is Mandelbrot's book, The Fractal Geometry of Nature, which is in the library; there is lots of recent information on the web.

The details of the recursive construction are illustrated below.

The left hand picture shows the basic shape; in the full fern each of the branches is recursively replaced by a scaled down copy of the shape. The right hand picture shows the next level of the construction.

As shown in the pictures, the two top branches are each half as long as the original main trunk, while the branch on the left is situated halfway along the main trunk. The angles which the branches make with the trunk are not crucial, but suggested values are shown on the diagram. Thus to draw a fern with a turtle, the turtle should start at the base of the trunk and do the following:

(a) Draw the trunk;

(b) Turn left by 30_ and draw a fern at half the scale;

(c) Turn right by (30 + 40)_ and draw a fern at half scale;

(d) Move back to halfway along the trunk; turn left by 80_ and draw a fern at 0.3 scale;

(e) Move back to the base of the trunk.


Related Discussions:- Create a program to produce a business speak phrase

Python style, Python  Style Software  engineering courses  often  pro...

Python  Style Software  engineering courses  often  provide very  rigid  guidelines on the style of programming, generally the appropriate value of indentation, or what  to us

Python program, Write a program that asks the user to enter a number of sec...

Write a program that asks the user to enter a number of seconds. The responses of the program will vary depending on the length of seconds: • If the number of seconds is under 60

Re.sub, how to use re.sub to seperate distint words and phrases when transl...

how to use re.sub to seperate distint words and phrases when translating text from English to Spanish or vis versa in python programming

Normalize a vector, Normalize a vector Let's imagine we want  to norma...

Normalize a vector Let's imagine we want  to normalize a vector  of three  variables;  that  is to compute a new  vector  of three values,  such that its size  is 1. Here is o

Data wrangling, http://www.expertsmind.com/questions/data-wrangling-3011642...

http://www.expertsmind.com/questions/data-wrangling-301164244.aspx

Euler method, python program of motion of a particle in viscus medium

python program of motion of a particle in viscus medium

Program to solve word search puzzles, This assignment involves writing a pr...

This assignment involves writing a program to solve word search puzzles. For example in the following word grid it is possible to find the words active, stock, ethernet and java. N

#Connect4, In English, specify a representation of the board game in Python...

In English, specify a representation of the board game in Python. The representation should capture the entire state of the game at one point in time. It may be helpful to first fi

Basic-learning to program in python , Depending on your  previous programmi...

Depending on your  previous programming background, we use different sides  through the available readings:   If you have never programmed before: you should start with a

Write Your Message!

Captcha
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