Questions
This function takes in a string as a parameter and prints the average number of characters...

This function takes in a string as a parameter and prints the average number of characters per word in each sentence in the string. Print the average character count per word for each sentence with 1 decimal precision (see test cases below).

  • Assume a sentence always ends with a period (.) or when the string ends.

  • Assume there is always a blank space character (" ") between each word.

  • Do not count the blank spaces between words or the periods as a character.

    Two example test cases are:

    >>> processString("An example. Dog")
    4.5 3.0
    (Note that the first sentence has 2 words with a total of 9 characters, so 4.5 characters per word on average. The second sentence has 1 word of 3 characters, so 3 characters on average.)

    >>> processString("This is the first sentence. The second sentence starts after the period. Then a final sentence")
    4.4 5.3 4.5

In: Computer Science

Using Python The script is to open a given file. The user is to be asked...

Using Python

  • The script is to open a given file. The user is to be asked what the name of the file is. The script will then open the file for processing and when done, close that file.
  • The script will produce an output file based on the name of the input file. The output file will have the same name as the input file except that it will begin with "Analysis-". This file will be opened and closed by the script.
  • The script is to process the file and calculate the following information and output the information to the file in the order presented here.
  • The script it to count the number of lines, the number of words, and the number of characters in the file and put this information out into the output file with appropriate labels for the reader to know what the numbers are. This information is to be echoed on the screen to the user.
    • You may find it easier to determine the number of words if you remove the punctuation, digits, and other non letter characters other than spaces before trying to count the words. Those items are not considered to be part of a word. Keep that in mind when referencing words in following instructions.
    • Count spaces, digits, punctuation and other non letter characters as characters though
  • The script is produce a list of all unique words in the file and the of times each word appears in the file. This list with frequency counts is to be put in the output file in alphabetical order and one word/frequency pair to a line. The format should be word (frequency count). Be sure there is a space between the word and the beginning parentheses. You will count words that appear only once. Due to the possible length of this list, you are not to echo this list to the screen, only place it in the output file.
  • The script is to produce a list of 2 word pairs found in the file that appear more than once. If a 2 word pair appears only once, it is not to be put into the output file. The format of the line in the output file should be the two word pair followed by the frequency count in parentheses as seen in the previous item involving unique words. This list is put out after the single word list. There is to be a heading to the list to let the user know that the information is changing and a blank line put in before the heading. This information is to be echoed on the screen to the user.
  • The last bit of information the script it to place into the output file is the total number of words, the average length of a word, the number of unique words, the average number of letters in the unique words, and the number of word pairs that have frequencies of 2 or more.   Properly label each item of information output in this section as well as placing a blank line before the section and giving the section a heading. This information is to be echoed on the screen to the user.
    • It is fully conceivable that the average number of letters in a word (length of a word) for the over all document is different than the average number of letters in a word for the unique word list. This is because a word such as "the" might appear multiple times in the file. In the first calculation, each instance of the is counted. In the second calculation, the word "the" is only counted 1 time on the list.
  • The script is to use solid programming practices like comments, self documenting variable names (also known as meaningful variable names) and easy to read and neat code.
  • You are to place a comment block at the very top of the script containing your name, the semester, the due date of the exam, and the instructor's name each on separate lines.

The logic is built to examine the process incoming data for specific items of information. This may need to be done in specific order with multiple processing steps.

You are to run your script of this test data file. Screen shot your interactions with the user for your submission document. Then place your analysis file, your python code file, and your submission document into a single zip file.

Some advice would be since you have the test data file, you can do these calculations by hand and check them against your analysis file to see if your program is working correctly.

In: Computer Science

Vocabulary: write the definition of the following words capital letters and give a synonymous for each...

Vocabulary: write the definition of the following words capital letters and give a synonymous for each word, then use the each word in a sentence. (TIRADE, WIZENED, PULCHRITUDINOUS, DISSEMINATE, CLEAVE)

In: Electrical Engineering

JAVA. A palindrome is a word or a phrase that is the same when read both forward and backward.

java please. 

A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never odd or even" (ignoring spaces). Write a program whose input is a word or phrase, and that outputs whether the input is a palindrome.

Ex: If the input is:

bob

the output is:

bob is a palindrome

Ex: If the input is:

bobby

the output is:

bobby is not a palindrome

Hint: Start by removing spaces. Then check if a string is equivalent to it's reverse.


Hint: Start by just handling single-word input, and submit for grading. Once passing single-word test cases, extend the program to handle phrases. If the input is a phrase, remove or ignore spaces.

In: Other

Suppose that a system uses DMA for data transfer from disk controller to main memory. Further...

Suppose that a system uses DMA for data transfer from disk controller to main memory. Further assume that it takes t1 nsec on average to acquire the bus and t2 nsec to transfer one word over the bus (t1 >> t2). After the CPU has programmed the DMA controller, how long will it take to transfer 1000 words from the disk controller to main memory, if

(a) word-at-a-time mode is used?

(b) burst mode is used?

Assume that commanding the disk controller requires acquiring the bus to send one word and acknowledging a transfer also requires acquiring the bus to send one word.

In: Computer Science

.text .globl main main:       lui $8, _______ # the address of pairs (SPIM:0x1000; Mars:0x1001)...

.text
.globl main

main:   
   lui $8, _______ # the address of pairs (SPIM:0x1000; Mars:0x1001)
   lw $9, 0(_____) # get the number of pairs (6) and store in $9
   ori $10, $0, 0 # use $10 to store the height sum
   ori $11, $0, 0 # use $11 to store the weight sum
   ori $12, $0, 0 # use $12 to count
   ori $13, $0, 0 # use $13 to store temp values;
addiu $8, $8, ___ # increase the address to get the first pair;
loop: ___________________ # jump to compute the average if count==number of pairs
   ____ $13, ____ # get height and store in $13
   add ___________ # update the height sum using $10
   addiu $8, $8, ___ # increase the address
   ____ $13, ____ # get weight and store in $13
   add ___________ # update the weight sum using $11
   addiu $8, $8, ___ # increase the address
   add ___________ # increase count
   j loop

ave:    div ________ # compute the average of height
   ___ $10 # store the height average in $10
   div ________ # compute the average of weight
   ___ $11 # store the weight average in $11
      
.data
pairs: .word 6 # number of pairs
.word 30, 60 # first pair: height, weight
.word 65, 51
.word 27, 67
.word 68, 270
.word 62, 115
.word 42, 43

## End of file

In: Computer Science

Using python, please complete these 4 exercises. Please limit your code to these skills: For loop...

Using python, please complete these 4 exercises. Please limit your code to these skills:

For loop

While loop

Input function

F strings

Tuples

Lists

Nested ifs

Elias

Exercise 1

Using the following list, do the following:

  1. Sort it in ascending order
  2. In a print statement, referencing the list and its index numbers, print the lowest value and the highest value.

[15, 70, 15, 38, 49, 98, 62, 89, 2, 21, 40, 74, 36, 36, 65, 1, 55, 16, 24, 56]

Exercise 2 (1 Point):

Using the following list, do the following:

1. Iterate through each element in the list

2. Print out whether the element is positive or negative or zero on a new line for each element.

[-2, 1, -2, 7, -8, -5, 5, 10, -6, 7]

Exercise 3 (2 Points):

Create a new list using the range function, appending the values from the range function's output into the list.

The range function must:

  1. Start at 1
  2. Stop at 50
  3. Skip every other number

Hint: Use either a for loop or a list comprehension

Exercise 4 (6 Points):

In this exercise, you will be required to do the following:

Take the following phrase: The only thing we have to fear is fear itself

  1. Convert it to a list
  2. Inspect each word in the list
    1. If the word in the list starts with a vowel (excluding y), then:
      1. add the letters "way" to the end of the word.
      2. EX: the word "and" would become "andway"
    2. If the word in the list does not start with a vowel (including y), then:
      1. take the first letter from the word and move it to the end of the word
      2. add to the end of the word, the letters "ay"
      3. EX: the word "money" would become "oneymay"
  3. Append each modified word to a new list
  4. convert the list to a string and print that string out
    1. HINT: use join()

So, the end result should be:

Hetay onlyway hingtay eway avehay otay earfay isway earfay itselfway

In: Computer Science

Java If the word begins with a single consonant followed by a vowel, move the consonant...

Java

  1. If the word begins with a single consonant followed by a vowel, move the consonant to the end of the word and add โ€œayโ€ after.
    • hello โ†’ [h]ello โ†’ ello[h] โ†’ elloh[ay] โ†’ ellohay
    • word โ†’ [w]ork โ†’ ork[w] โ†’ orkw[ay] โ†’ orkway
  2. If the word begins with a consonant cluster (more than one consonant followed by a vowel), move the entire consonant cluster to the end of the word and add โ€œayโ€ after.
    • start โ†’ [st]art โ†’ art[st] โ†’ artst[ay] โ†’ artstay
    • through โ†’ [thr]ough โ†’ ough[thr] โ†’ oughthr[ay] โ†’ oughthray
  3. If the word begins with a vowel, simply add โ€œyayโ€ to the end of the word.
    • on โ†’ [o]n โ†’ on[yay] โ†’ onyay
    • a โ†’ [a] โ†’ a[yay] โ†’ ayay
    • unique โ†’ [u]nique โ†’ unique[yay] โ†’ uniqueyay

If the word contains the letter "y", there are some special rules that must be applied:

  1. If the word begins with the letter โ€œyโ€ followed by a vowel, treat the โ€œyโ€ as a consonant.
    • yes โ†’ [y]es โ†’ es[y] โ†’ esy[ay] โ†’ esyay
    • yellow โ†’ [y]ellow โ†’ ellow[y] โ†’ ellowy[ay] โ†’ ellowyay
  2. If the word begins with a consonant or consonant cluster followed by the letter โ€œyโ€, treat the โ€œyโ€ as a vowel.
    • thy โ†’ [th]y โ†’ y[th] โ†’ yth[ay] โ†’ ythay
    • rhythm โ†’ [rh]ythm โ†’ ythm[rh] โ†’ ythmrh[ay] โ†’ ythmrhay

In the rules above, the letters "a", "e", "i", "o", and โ€œuโ€ are considered vowels, and all other letters are considered consonants, except for โ€œyโ€ as described above.

Other Characters

Beyond translating words, there are a few other rules to be aware of.

  1. If the original wordโ€™s first letter is capitalized, the translated word should also have its first letter capitalized.
    • Hello โ†’ [H]ello โ†’ ello[h] โ†’ elloh[ay] โ†’ [e]llohay โ†’ Ellohay
    • I โ†’ [I] โ†’ I[yay] โ†’ Iyay
  2. If the original word ends in a punctuation, move the punctuation to the end of the translated word.
    • hello. โ†’ hello[.] โ†’ [h]ello โ†’ ello[h] โ†’ elloh[ay] โ†’ ellohay[.] โ†’ ellohay.

Program Specification

Input

Our program should accept input in one of two ways:

  1. If a command-line argument is provided, it should read input from the file given as that argument.
  2. If no command-line arguments are provided, the program should read input directly from the terminal.

Each run of the program may consist of multiple lines of input. The total number of lines will vary. Input will end with either an EOF (end of file) marker, or a blank line of input. Your program should stop accepting input when either of these situations occurs.

Each line of input will contain words to be converted to Pig Latin. You may assume that the lines will only contain letters a-z A-Z, spaces , and common punctuation marks that are placed at the end of words !.,?.

You may assume that words are separated by spaces, but they may have attached punctuation marks at the end.

Input 1

hello world

Output 1

ellohay orldway

Input 2

A good day to Kansas!

Output 2

Ayay oodgay ayday otay Ansaskay!

In: Computer Science

(IN YOUR WORD) write a 400-word long, five paragraph essay about effect of Noise pollution (SUPPORTED...

(IN YOUR WORD) write a 400-word long, five paragraph essay about effect of Noise pollution

(SUPPORTED with a clear THESIS STATEMENT and five well-developed paragraphs)

In: Psychology

Here is a Problem I need to solve: 5) Write a function to determine is a...

Here is a Problem I need to solve:

5) Write a function to determine is a given word is legal. A word is illegal if it contains no vowels. For this problem,
the letter Y is considered to be a legal vowel. Pass in a word to this function and it will determine if the word is
legal or not. You can make the following assumptions about the word you a passing to this function.
1) The string being passed is a combination of letters only (no non-letter check needed)
2) The string being passed is null terminated
3) Letters may be capital or lower case and it has no effect on whether its a word

I think I am in the right direction below. But the problem is my proposed solution involves two separate functions. My question is how I can make this one function?

  1. int isVowel(char c){

  2. if(c>='A' && c<='Z')

  3. c=c+32;

  4. if(c=='a' || c=='e' || c=='i'|| c=='o'|| c=='u'|| c=='y')

  5. return 1;

  6. else

  7. return 0;

  8. }

  9. int validString(char *c){

  10. int i;

  11. for(i=0;c[i]!='\0';i++)

  12. if(isVowel(c[i]))

  13. return 1;

  14. return 0;

  15. }

In: Computer Science