Questions
- Write a function with a parameter called A (which is between 1 and 10) and...

- Write a function with a parameter called A (which is between 1 and 10) and prints the multiplication table for 1 to A. • Note: Do not need to draw the horizontal and vertical lines. • Example for A = 10.

In: Computer Science

In Python write a program that prompts the user for a file name, make sure the...

In Python write a program that prompts the user for a file name, make sure the file exists and if it does reads through the file, count the number of times each word appears and then output the word count in a sorted order from high to low.

The program should:

  • Display a message stating its goal
  • Prompt the user to enter a file name
  • Check that the file can be opened and if not ask the user to try again (hint: use the try/except structure)
  • Count the number of times each word appears in the file, regardless if in lowercase or uppercase (hint: use dictionaries and the lower() function)
  • Display the word count in order from high to low
  • If a few words have the same count, sort the display in an alphabetic order
  • For example, for the attached file NYT2.txt, the top five words in the output should be

the - 7

in - 6

to - 5

and - 4

of - 4

Remember:

  • DO NOT use more advanced functions than needed.
  • Make sure to include comments that explain all your steps (starts with #).
  • Run the program a few times to make sure it executes and meets all the requirements.

NYT2.txt file below:

Fact-Checking Trump’s Orlando Rally: Russia, the Wall and Tax Cuts
President Trump delivered remarks in Florida in a formal start to his re-election effort.
Deutsche Bank Faces Criminal Investigation for Potential Money-Laundering Lapses        
Federal authorities are focused on whether the bank complied with anti-money-laundering laws, including in its review of transactions linked to Jared Kushner.
Five NY1 Anchorwomen Sue Cable Channel for Age and Gender Discrimination
The women, including Roma Torre, say their careers were derailed after Charter Communications bought New York’s hometown news station in 2016.
Hypersonic Missiles Are Unstoppable. And They’re Starting a New Global Arms Race.
The new weapons — which could travel at more than 15 times the speed of sound with terrifying accuracy — threaten to change the nature of warfare.
Nxivm’s Keith Raniere Convicted in Trial Exposing Sex Cult’s Inner Workings
Mr. Raniere set up a harem of sexual “slaves” who were branded with his initials and kept in line by blackmail.
Jamal Khashoggi Was My Fiancé. His Killers Are Roaming Free.
Washington hasn’t done enough to bring the murdered Saudi columnist’s killers to justice.

In: Computer Science

Create a BMI calculator that reads the user’s weight and height (providing an option for the...

Create a BMI calculator that reads the user’s weight and height (providing an option for the user to select which formula to use), and then calculates and displays the user’s body mass index. Also, display the BMI categories and their values from the National Heart Lung and Blood Institute: http://www.nhlbi.nih.gov/health/educational/lose_wt/BMI/bmicalc.htm (Links to an external site.) so the user can evaluate his/her BMI.

Java Version

In: Computer Science

i j(i) i j(i) i j(i) i j(i) 0 -0.0499 7 -0.08539 13 0.144812 19 0.08021...

i

j(i)

i

j(i)

i

j(i)

i

j(i)

0

-0.0499

7

-0.08539

13

0.144812

19

0.08021

1

0.107506

8

0.062922

14

-0.0499

20

-0.30103

2

-0.06719

9

-0.04444

15

-0.18366

21

-0.33834

3

-0.04717

10

0.219422

16

-0.02898

22

0.058373

4

-0.09176

11

0.083849

17

0.08021

23

0.79083

5

-0.25918

12

-0.02261

18

-0.14271

24

0.130254

6

0.055643

25

-0.10177

  1. (3 points) Please encipher the following plaintext with Caesar Cipher and the encryption key of 10: TODAYISTUESDAY;
  1. (3 points) In a Caesar cipher, the encryption key is 5, and the ciphertext is LTTIQZHPBNYMDTZWJCFR, please decipher it;

  1. (6 points) Decipher the following ciphertext, which was enciphered using the Caesar cipher: TEBKFKQEBZLROPBLCERJXKBSBKQP.
  1. (4 points) Let k be the encipherment key for a Caesar cipher. The decipherment key differs; it is 26 – k. One of the characteristics of a public key system is that the encipherment and decipherment keys are different. Why then is the Caesar cipher a classical cryptosystem, not a public key cryptosystem? Be specific.

In: Computer Science

Python3 question. Suppose I have a undirect and unweighted graph with vertex list type, here is...

Python3 question.

Suppose I have a undirect and unweighted graph with vertex list type, here is the code of the graph.

graph = { "a" : ["c"],
          "b" : ["c", "e"],
          "c" : ["a", "b", "d", "e"],
          "d" : ["c"],
          "e" : ["c", "b"],
          "f" : []
        }

I want to use this to create a DFS method. How can I use stack only to finish the work?

In: Computer Science

Recursion java: 1. Write a recursive algorithm to add all the elements of an array of...

Recursion java:

1. Write a recursive algorithm to add all the elements of an array of n elements

2. Write a recursive algorithm to get the minimum element of an array of n elements

3. Write a recursive algorithm to add the corresponding elements of two arrays (A and B) of n elements. Store the results in a third array C

.4. Write a recursive algorithm to get the maximum element of a binary tree

5. Write a recursive algorithm to get the number of elements of a binary tree

In: Computer Science

Python3 question. Suppose I have a undirect and unweighted graph with vertex list type, here is...

Python3 question.

Suppose I have a undirect and unweighted graph with vertex list type, here is the code of the graph.

graph = { "a" : ["c"],
          "b" : ["c", "e"],
          "c" : ["a", "b", "d", "e"],
          "d" : ["c"],
          "e" : ["c", "b"],
          "f" : []
        }

I want to use this to create a BFS method. How can I use queue only to finish the work?

In: Computer Science

I am building a tik tac toe board using python and the function I am using...

I am building a tik tac toe board using python and the function I am using is not working to check to see if the board is full. I'll include the code for the board and the function to check if it is full. X's and O's are being inserted and the function is suppose to stop running when is_full(board) returns True. ch is either x or o

board = []

   for i in range(3):

    board.append([])

    for j in range(3):

    board[i].append(' ')

   return board

def is_full(board):

   """ Checking for board full """

   for lst in board:

    for ch in lst:

    if ch == ' ':

    return False

In: Computer Science

Please use python3 Create the function team_average which has the following header def team_average(filename): This function...

Please use python3

Create the function team_average which has the following header

def team_average(filename):

This function will return the average number of games won by the Red Sox from a text file with entries like this

2011-07-02      Red Sox @  Astros       Win 7-5
2011-07-03      Red Sox @  Astros       Win 2-1
2011-07-04      Red Sox vs Blue Jays    Loss 7-9

This function should create a file object for the file whose name is given by the parameter filename.

If the file cannot be opened, use a try/except statement to print an error message and don't do any further work on the file.

The function will count the number of lines and the number of games the Red Sox won and use these values to compute the average games won by the team.

This average should be expressed as an integer.

Test Code

Your hw2.py file must contain the following test code at the bottom of the file

team_average('xxxxxxx')
print(team_average('red_sox.txt'))

For this test code to work, you must copy into your hw2 directory the file red_sox.txt from /home/ghoffman/course_files/it117_files.

To do this go to your hw2 directory and run cp /home/ghoffman/course_files/it117_files/red_sox.txt .

Suggestions

Write this program in a step-by-step fashion using the technique of incremental development.

In other words, write a bit of code, test it, make whatever changes you need to get it working, and go on to the next step.

  1. Create the script hw2.py using nano or some other Unix text editor.
    Enter the header for team_average into the script.
    Under this header write the Python statement pass.
    Copy the test code above into the script.
    Make the script executable.
    Run the script.
    If all you see is None, proceed to the text step.
  2. Remove the pass statement.
    In its place write the function code to open the file for reading.
    This code should print an error message and exit the function if the file cannot be opened for reading.
    Run the script.
    You should see
    Cannot open xxxxxxx
    None
  3. Modify the function so it prints out the lines of the file.
  4. Modify the function to use the split string method to create a list from the from the different fields in a line. Print this list.
  5. For each line, get the value of the won_lost field and print it.
    This field is second to last entry in the list you created by using the split method.
    The lists will have different lengths, since some team have a single word as their name, and others have two words, e.g. White Sox.
    The easiest way to get the second to last field is to use a negative index.
    Print the value of won_lost field.
  6. Comment out or delete the line that prints the won_lost field.
    Initialize an accumulator to count the number of lines.
    Increment this accumulator inside the for loop.
    Return the total number of lines.
  7. Initialize an accumulator to count the number of Red Sox wins.
    In the for loop increment this accumulator every time the value of won_lost is "Win".
    Return the number of games won.
  8. Change the return statement so it returns integer percent of the number of games the Sox won.

Output

When you run the completed script, you should see

Error: Unable to open xxxxxxx
76

In: Computer Science

What are the security design principles? Explain each with an appropriate example.

What are the security design principles? Explain each with an appropriate example.

In: Computer Science

for C program 10 by 10 char array. char 0-9 as rows and char a-j as...

for C program 10 by 10 char array. char 0-9 as rows and char a-j as collumns.

In: Computer Science

Write a java method that creates a two dimensional char array after asking the user to...

Write a java method that creates a two dimensional char array after asking the user to input a String text and String key consisting of integers only, such that

int rows=(int)Math.ceil(text.length()/key.length()); // or int rows=(int)Math.ceil(text.length()/key.length()); ?

int columns= key.length();

int remainder= text.length() % key.length(); // such that the last row avoids taking an index beyond the string text by making columns - remainder

The method fills the 2d array with letters a String entered by the use (row by row). The method then shifts the columns of the array based on key.

After changing the columns, the method returns a String of all the characters in the 2d array but written column by column.

text = Sara;

key= 312

For example, the initial 2d array is

S A R
A

transformed into

R S A
A

The final retuned string is RSAA

In: Computer Science

Using what you know about how to take inputs and make outputs to the console, create...

Using what you know about how to take inputs and make outputs to the console, create a check printing application. Your application will read in from the user an employee's name and salary, and print out a Console Check similar to the following. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > | $1,000,000 | > > > > ___Pay to the Order of___ Johnny PayCheck > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Please only use technique from chapter 1 through 3 in C++ from control structure through object 9th edition

In: Computer Science

Library Management System allows the user to borrow and return the books. The book is identified...

Library Management System allows the user to borrow and return the books. The book is identified by book name, accession number, item category, due date, due time, and status. Before the user proceeds to borrow or return the books, they need to register for an account. Each user can have only one account. The user can be a staff or student. Each user is identified by ID number, name, school/department name, address. The books are arranged on a shelf. The shelf can be of two categories: open shelf or red spot. The user is allowed to reserve the book, in case, if the book is already borrowed by someone. While reserving a book, the user needs to specify the user name, ID number, book name, and accession number.

##Based on the above scenario, draw a Class Diagram. Your diagram should include attributes, methods and multiplicity.

In: Computer Science

File Compression - Student should submit a one-page paper summarizing the student’s research into compression programs...

File Compression - Student should submit a one-page paper summarizing the student’s research into compression programs associated with the filename extensions .zip, .sit, .sitx, and .exe, as well as whether those files would be self-extracting and which formats are associated with Windows and which with OS X. Also included should be a summary of at least two compression programs compatible with the computer the student uses most often, including their costs and capabilities

In: Computer Science