Questions
Here is a series of address references given as word addresses: 18, 19, 27, 16, 21,...

Here is a series of address references given as word addresses: 18, 19, 27, 16, 21, 0, 64, 48, 19, 11, 19, 22, 4, 27, 6, and 27. Assuming a direct-mapped cache with 16 one-word blocks that is initially empty, label each reference in the list as a hit or a miss and show the final contents of the cache.

In: Computer Science

Please discuss about Corona virus what and what is the impact of this word on American...

Please discuss about Corona virus what and what is the impact of this word on American culture? What about other cultures? Why is the history of corona virus important for us to understand? What can we gain from this knowledge? Has your research led you to believe this word will grow into something else? What will it grow into and why does that matter?

In: Biology

5. Take user input and give corresponding output. User will enter a sentence. The program will...

5. Take user input and give corresponding output.

User will enter a sentence. The program will output the word that appears most frequently in this sentence. If there are multiple words with same frequency, output the first of these words.

Please enter a sentence: I like batman because batman saved the city many times. The most frequent word is: batman The frequency is: 2

PYTHON

In: Computer Science

A random rearrangement doe not separate out between repeated letters. Consider word CHRISTMASTIME. a) What's the...

A random rearrangement doe not separate out between repeated letters. Consider word CHRISTMASTIME.

a) What's the expected # vowels in first three letters of random rearrangement of CHRISTMASTIME?

b) What's probability that all the S's happen before all the I's in random rearrangement of CHRISTMASTIME?

c) What's probability that word CHRIST happens in consecutive letters of uniform rearrangement of CHRISTMASTIME?

In: Math

Evaluate the impact of exposure to societal violence on the developmental process during middle childhood. Refer...

Evaluate the impact of exposure to societal violence on the developmental process during middle childhood.

Refer to any scholarly article that connects to the topic to create a Word document with a 500-750 word-count. Include factual connections with in –text citations and a reference page. All writing must adhere to APA standard format. Minimum of two references including text are required.

In: Psychology

Q 4 A computer program translates texts between different languages. Experience shows that the probability of...

Q 4
A computer program translates texts between different languages. Experience shows that the probability of a word being incorrectly translated is 0.002.
We enter a text with 5000 words.
What is the probability that no word is translated incorrectly? (Tips, Po)
What is the probability that at most 2 words will be translated incorrectly?
What is the probability that 3 or more words are translated incorrectly?

In: Math

Write a JAVAprogram that reads a word and prints all its substrings, sorted by length. It...

Write a JAVAprogram that reads a word and prints all its substrings, sorted by length. It then generates a random index between 0 and the length of the entered word, and prints out the character at that index.

For example, if the user provides the input "rum", the program prints
r
u
m
ru
um
rum

The random index generated is 1. The character at index 2 is u.

In: Computer Science

Hangman We're going to write a game of hangman. Don't worry, this assignment is not nearly...

Hangman

We're going to write a game of hangman. Don't worry, this assignment is not nearly as difficult as it may appear.

The way hangman works (for this assignment - we are doing a simplified game) is as follows:

  • the computer will choose a word. (For this version, a word is selected from a static list encoded into the program -- so the words are pretty limited). Let's say the word is "cocoa".
  • the computer shows the user how many letters are in the word by displaying a "space" for each letter.   For our example, "cocoa" would be shown as:   _ _ _ _ _
  • the user guesses a letter
  • if the guessed letter is in the secret word, the computer updates the "_ _ _ _ _" representation to show where the chosen letter resides. So, for instance, if the user chose "o", the representation would be updated to be "_o_o_"
  • the user guesses another letter ... and the game continues until the user fills in all the letters.

I have provided you with skeleton code below. You must use this code. You will fill in the code for the places where you see comments that start with "TODO". Do NOT modify any of the rest of the code. No further modifications are necessary. You simply need to add the code that is specified and the program will work.

Most of the work is adding code to fill in the functions. How can you test that you have done this correctly? Each function (except for main()) is independent -- it does only one job and does not call any other functions. Therefore, you can test each function independently. Think of each as a separate question on an assignment. If you wish, you can cut and paste the skeleton of the function into another python file and isolate it from the rest of the code. To test if the function works the way you want it to, call the function with some made-up parameter values and print the result. So, for instance, to test the function updateUsedLetters(), you could do the following:

uLetters = "abcd"  #this fabricated string represents the letters the user has already chosen
guess = "z"    #this is a user guess (no input required ..... just make up a letter)
uLetters = updateUsedLetters(uLetters, guess)
print(uLetters)   #I expect to see "abcdz" returned

Testing this function doesn't depend at all on the rest of the program. Once I know that it works, I can continue on and work on the other functions.  

The program is not going to run until you have all the functions complete and working -- so you really need to test each one individually. I will go over this process in the class on Tuesday.


Here is the skeleton code. Take some time to look at the structure and understand how it works. Notice the way the functions are structured --- each function does one task and each receives the information that it needs to do the job and returns the answer. This answer is used in the calling function.

You can cut and paste this into a new python file. It is easier to read when you put it into a Python window.   When you hand in your code, remove all the instructional #TODO comments. You do not have to add to the docstrings but you should read them to understand more about how each function works.

'''
This is a simplified version of a hangman game. The computer chooses a word
from a pre-defined list of words and the user guesses letters until they have
filled in all the letters in the word.

Author:  
Student Number:  
Date:  Oct, 2020
'''
import random

def getSecretWord():
    """
    This function chooses a word from the list of potential secret
    words.
    Parameters:  None
    Return Value: a string representing the secret word
    """

    #DO NOT MODIFY THIS FUNCTION
    
    potentialWords = ["tiger", "lion", "elephant", "snake", "zebra"]

    #random.randint(0, 4) will generate an integer between 0 and 4
    #this is then used to select a value from potentialWords

    return potentialWords[random.randint(0,4)]

def printStringWithSpaces(word):
    """
    This function prints the blank representation ("___") of the
    secret word on the screen with spaces between each underscore
    so that the user can better see how many letters there are.
    Parameter: string
    Return Value:  None
    """

    #TODO -- complete this function so that it prints "word" (a string)
    #so that there are spaces between each letter.
    #eg:  word = "watch", the function prints w a t c h
    #you will need a loop to do this.
    #recall that print() can be given a parameter end=' ' to keep all output
    #on the same line.

    #PUT YOUR CODE HERE

    #leave the following two lines at the end of your function for nicer output
    print()
    print()


def convertWordToBlanks(word):
    """
    Creates a string consisting of len(word) underscores.
    For example, if word = "cat", function returns "___"

    Parameter: string
    Return Value: string
    """

    #TODO -- complete this function so that it produces a string with
    #underscores representing the parameter "word" (which is a string).
    #eg:  word = "watch", the function returns "_____"  (5 underscores)
    #You will need a loop for this.  Also, a return statement.

    #leave this line (and use the variable newString in your code
    newString = ""  #start with an empty string and add onto it

    #PUT YOUR CODE HERE
    

def updateRepresentation(blank, secret, letter):
    """
    This function replaces the appropriate underscores with the guessed
    letter.
    Eg.  letter = 't', secret = "tiger", blank = "_i_er" --> returns "ti_er"
    Paramters:   blank, secret are strings
                letter is a string, but a single letter.
    Returns:  a string
    """

    #TODO -- complete this function so that it produces a new string
    #from blank with letter inserted into the appropriate locations.
    #For example:
    #   letter = 't', secret = "tiger", blank = "_i_er" --> newString "ti_er"
    #newString should be returned.
    #hint:
    #iterate through each character of secret by index position
    #   check to see if letter = current character at index position
    #      if yes, add this letter to newString
    #      if no, add the letter from blank found at index position

    #leave this line (and use the variable newString in your code
    newString = ""

    
def updateUsedLetters(usedLetters, letter):
    """
    This function concatenates the guessed letter onto the list of letters
    that have been guessed, returning the result.
    Parameters: string representing the used letters
                string respresenting the current user guess
    Return Value:  string
    """

    #TODO -- complete this function so that it returns the concatentation
    #of the string usedLetters with the letter. 
 
    pass #remove this line -- pass is a "do nothing" keyword

    

def main():
    """
    This implements the user interface for the program.
    """
    usedLetters = "" #no letters guessed yet
    secret = getSecretWord()
    print("The secret word is ", secret)

    #TODO - add one line of code here to call the function
    #convertWordToBlanks to convert the secret word
    #to a string of underscores.  Assign the result to
    #the variable blank as shown below.
    blank = #ADD YOUR FUNCTION CALL HERE.  

    
    printStringWithSpaces(blank)

    
    while blank != secret:
        userGuess = input("Please enter a single letter guess: ")
        
        #check for valid input
        while not(userGuess.isalpha()) or len(userGuess) != 1:
            userGuess = input("Please enter valid input(a single letter guess):")

        #TODO:  Add one line of code here (at the same level of indentation of
        #this comment) to check that userGuess is NOT in the string usedLetters.
        #ADD YOUR CODE HERE

            print("You have guessed ", userGuess)

            if userGuess in secret:
                #letter is in the secret word so update the blank representation
                blank = updateRepresentation(blank, secret, userGuess)
            
            printStringWithSpaces(blank)

            #add the letter to the string of used letters 
            usedLetters = updateUsedLetters(usedLetters, userGuess)
            
        else:
            #letter has been guessed already -- update the user
            print("You have already guessed that letter!!!")
            print("Here are the letters you have guessed so far: ")
            printStringWithSpaces(usedLetters)
            
        
    print("You got it!!  The word was", secret)


main()

In: Computer Science

VBA question, write a function check keyword in a string. Question: Function sentimentCalc(tweet As String) As...

VBA question, write a function check keyword in a string.

Question:

Function sentimentCalc(tweet As String) As Integer

This function should check each word in the tweet and if the word exists as one of the keywords in the positive list or negative list it should impact the overall sentiment value. The positive list and negative list words exist in the keywords sheet. Access the keywords as ranges within your VBA code. The case of the word is inconsequential. For instance, happy, HAPPY, or hApPy are all treated as positive words regardless of their case (Hint: StrComp).

We have a keyword excel show that which word is positive and which is negative. How to get the keyword please see the hit part below.

If the word is in the positive list, it should increase the sentiment value by 10, if it is in the negative list it should decrease it by 10.

For instance, if the positive list includes “happy”, “rally”, “growth” and the negative list includes “crash”, “scam”, “bad” then:

If the Tweet is “I am Happy that Bitcoin is showing growth.”. The sentiment value will be 10 + 10 = 20

If the Tweet is “I am happy that Bitcoin is a scam and will CRASH!” The sentiment value will be 10 – 10 – 10 = -10

You must remove the following punctuation characters from the tweet text in your VBA code before calculating the sentiment: ! . , ? : ) ( ;

You may do this using multiple lines each calling the Replace function or with an array, loop and one call to the Replace function. Both methods will be marked as correct.

HIT:

You will need to use the string functions StrCom p, Split and Replace In this function.To get the ranges from the keywords Sheet use Worksheet and Range object like so:

Dim positive As Range

Set positive = Worksheets("keywords").Range("A2:A76")

Dim negative As Range

Set negative = Worksheets("keywords").Range("B2:B76")

This will give you the range A2:A76.From the sheet namedkeywords As the variable named positive.You can do the same for the negative range (but with different cell references And variable names).

You will need to use nested loops. One to go through each word in the keywords and one to Go through each word in the tweet text.

In: Computer Science

Part 3: Anagram Arranger (20 pts) Overview Create a file called Anagram.java, which reads a series...

Part 3: Anagram Arranger (20 pts)

Overview

  • Create a file called Anagram.java, which reads a series of words input from a file.
  • For each word read from the file, the user will have the option to swap letters within that word.
  • You are required to use your doubly-linked list class to receive credit for this part of the assignment.
  • Therefore, your word should be stored as a List of Characters or Strings (each String being one letter).
  • After the user has rearranged the word, it should be written to a file, including the changes the user has made.

Specifications

  • The program should welcome the user with the message Welcome to the Anagram Arranger!
  • It should then prompt the user to enter the name of a file.
  • Provided the user enters a correct file name (see section regarding error checking below), then the program will read in all of the words in the file, one-by-one.
  • Each word should be stored in a List of Characters or Strings (each String being one letter).
  • It will display the word, along with its corresponding number, with the message:  Word #<count> is <word>
  • See below for examples.
  • The user will then be prompted to enter the position of two different letters in the word that the user wants to be swapped.
  • The program will verify the user choice by re-printing the word with carrots beneath the selected letters.
  • The user will then be required to confirm his or her choice with the message: Enter the position numbers of the two letters you wish to swap:
    • The program should accept four different input options from the user -- y, Y, yes, and Yes -- to indicate consent.
  • If the user indicates "no", the word will be reprinted with a prompt to enter the position of two different letters.
  • If the user enters yes, then the program should swap the two selected letters, and then prompt the user to indicate whether he or she would like to swap additional letters in the word.
    • The program should accept four different input options from the user -- y, Y, yes, and Yes -- to indicate consent.
  • The user should be able to continue swapping letters indefinitely.
  • Once the user no longer wishes to swap, the current version of the word should be written to a file named output.txt
  • Please see below for an incomplete example run:

Welcome to the Anagram Arranger!

Please enter the name of your input file: spooky.txt

Word #1 is zombie
1: z
2: o
3: m
4: b
5: i
6: e

Enter the position numbers of the two letters you wish to swap: 1 2

z o m b i e
^ ^  
Are these the letters you wish to swap? (y/n): y

The new word is: o z m b i e

Want to keep rearranging? (y/n): y

1: o
2: z
3: m
4: b
5: i
6: e

Enter the position numbers of the two letters you wish to swap: 3 5

o z m b i e
    ^   ^        
Are these the letters you wish to swap? (y/n): y

The new word is: o z i b m e

Want to keep rearranging? (y/n): n

Word #2 is mummy
1: m
2: u
3: m
4: m
5: y

Enter the position numbers of the two letters you wish to swap:  etc...

A complete Example:

This example assumes an input file named words.txt with the following content - however, the user should be able to enter any file name and the file can contain any number of words:

Spring
Summer
Fall
Winter

Output of running Anagram.java

Welcome to the Anagram Arranger!

Please enter the name of your input file: abc.txt

Sorry. I cannot find a file by that name!
Please enter the name of a valid input file: 123.txt

Sorry. I cannot find a file by that name!
Please enter the name of a valid input file: words.txt

Word #1 is Spring
1: S
2: p
3: r
4: i
5: n
6: g

Enter the position numbers of the two letters you wish to swap: 3 5

S p r i n g
    ^   ^       
Are these the letters you wish to swap? (y/n): y

The new word is: S p n i r g

Want to keep rearranging? (y/n): yes

1: S
2: p
3: n
4: i
5: r
6: g

Enter the position numbers of the two letters you wish to swap: 1 6

S p n i r g
^         ^         
Are these the letters you wish to swap? (y/n): yes

The new word is: g p n i r S

Want to keep rearranging? (y/n): n

Word #2 is Summer
1: S
2: u
3: m
4: m
5: e
6: r

Enter the position numbers of the two letters you wish to swap: 2 3

S u m m e r
^ ^   
Are these the letters you wish to swap? (y/n): Yes

The new word is: S m u m e r

Want to keep rearranging? (y/n): Yes

1: S
2: m
3: u
4: m
5: e
6: r

Enter the position numbers of the two letters you wish to swap: 4 5

S m u m e r
      ^ ^       
Are these the letters you wish to swap? (y/n): y

The new word is: S m u e m r

Want to keep rearranging? (y/n): n

Word #3 is Fall
1: F
2: a
3: l
4: l

Enter the position numbers of the two letters you wish to swap: 1 2

F a l l
^ ^
Are these the letters you wish to swap? (y/n): y

The new word is: a F l l

Want to keep rearranging? (y/n): n

Word #4 is Winter
1: W
2: i
3: n
4: t
5: e
6: r

Enter the position numbers of the two letters you wish to swap: 1 3

W i n t e r
^   ^   
Are these the letters you wish to swap? (y/n): n
1: W
2: i
3: n
4: t
5: e
6: r

Enter the position numbers of the two letters you wish to swap: 1 4

W i n t e r
^     ^     
Are these the letters you wish to swap? (y/n): y

The new word is: t i n W e r

Want to keep rearranging? (y/n): y

1: t
2: i
3: n
4: W
5: e
6: r

Enter the position numbers of the two letters you wish to swap: 2 5

t i n W e r
^     ^       
Are these the letters you wish to swap? (y/n): y

The new word is: t e n W i r

Want to keep rearranging? (y/n): y

1: t
2: e
3: n
4: W
5: i
6: r

Enter the position numbers of the two letters you wish to swap: 3 4

t e n W i r
    ^ ^     
Are these the letters you wish to swap? (y/n): y

The new word is: t e W n i r

Want to keep rearranging? (y/n): n

Bye!

Corresponding output.txt for above example:

g p n i r S
S m u e m r
a F l l
t e W n i r

Required Error Checking

  • Your Anagram.java should also do error checking for the following cases only:
  1. The user inputs a position number that is higher than the position of the last character in the word
  2. The user reverses the order of the two positions by giving the higher number followed by the lower number
  3. The user enters the same position number twice.
  • For the above errors, the program should print the message Invalid entry! and allow the user to try again, as shown in the example below.
  • Additionally, the program should correctly handle the below error:
  1. The user enters an incorrect name for a file.
    1. Error checking should be completed using a loop to handle multiple invalid inputs
    2. Error message must be:

Sorry. I cannot find a file by that name!
Please enter the name of a valid input file:

  • Please see below for examples of how to handle invalid input.


Error Checking Example:

Welcome to the Anagram Arranger!

Please enter the name of your input file: ddd.txt

Sorry. I cannot find a file by that name!
Please enter the name of a valid input file: nnn.txt

Sorry. I cannot find a file by that name!
Please enter the name of a valid input file: splooky.txt

Sorry. I cannot find a file by that name!
Please enter the name of a valid input file: spooky.txt

Word #1 is zombie
1: z
2: o
3: m
4: b
5: i
6: e

Enter the position numbers of the two letters you wish to swap: 4 2

Invalid entry!

1: z
2: o
3: m
4: b
5: i
6: e

Enter the position numbers of the two letters you wish to swap: 1 10

Invalid entry!

1: z
2: o
3: m
4: b
5: i
6: e

Enter the position numbers of the two letters you wish to swap: 2 2

Invalid entry!

1: z
2: o
3: m
4: b
5: i
6: e

Enter the position numbers of the two letters you wish to swap: 2 3

z o m b i e
^ ^    
Are these the letters you wish to swap? (y/n): yes

The new word is: z m o b i e

Want to keep rearranging? (y/n): etc.

In: Computer Science