Assignment 3 – Incorporating a Table into a Document.
Create a Word document and title it “College Expenses”. In the Word document, insert a table with at least 5 rows and 5 columns. Insert>Table.
Tell me about your college expenses you have by filling this table with subjects and data. Then write two paragraphs telling me about the information you provided in the table. Bold and color table heading. Example of table:
College Expenses
Tuition
Books
Computer/Internet
Other supplies
Science Class
Math class
C.I.S. Class
English Class
Give the page a proper title. Align left all your data in the table. Align left your paragraphs below the table. Indent each paragraph. Make sure your name is on the paper. Get creative and have fun!
In: Computer Science
Looking to see how to figure this out. So far when I break apart the coding it works but when it is all together it doesn't,
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:
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.
here is my code thus far:
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
"""
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
"""
#loop that places a space between each letter
for ch in word:
print(ch, ' ', end = '')
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
for ch in word:
empty = print(('_' + newString), end = '')
return empty
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 = ""
countIndex = 0
while countIndex<len(secret):
for ch in secret:
if ch == letter:
newString = blank[:countIndex] + letter +
blank[countIndex+1:]
countIndex +=1
else:
countIndex += 1
return 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
"""
usedLetters = "" + letter
return usedLetters
def main():
"""
This implements the user interface for the program.
"""
usedLetters = "" #no letters guessed yet
secret = getSecretWord()
print("The secret word is ", secret)
#convert the secret word to a string of underscores.
blank = convertWordToBlanks(secret)
printStringWithSpaces(secret)
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
if userGuess not in usedLetters:
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
C Code! I need all of the \*TODO*\ sections of this code completed.
For this dictionary.c program, you should end up with a simple English-French and French-English dictionary with a couple of about 350 words(I've provided 5 of each don't worry about this part). I just need a way to look up a word in a sorted array. You simply need to find a way to identify at which index i a certain word appears in an array of words and print out the corresponding French word, at the same index i.
#include <stdio.h>
#include <string.h>
const int NUMBER_ENTRIES = 352;
const char* english_NUMBER_ENTRIES[5]= {"war","size", "her","song","time"};
const char* french_NUMBER_ENTRIES[5] = {"guerre","taille","sa", "chanson","temps"};
int main(int argc, char **argv)
{
const int BUFFER_LENGTH = 128;
char c, t;
char user_word[BUFFER_LENGTH];
enum { ENGLISH_FRENCH, FRENCH_ENGLISH } direction;
int i;
/* TODO: Add additional declarations here */
printf("Dictionary\n\n");
printf("English-French Dictionary\n\n");
do {
printf("Enter e for English-French\n");
printf("Enter f for French-English\n");
scanf("%c", &c);
scanf("%c", &t);
} while (!((c == 'e') || (c == 'f')));
switch (c) {
case 'e':
direction = ENGLISH_FRENCH;
break;
case 'f':
direction = FRENCH_ENGLISH;
break;
}
printf("Please enter a word in ");
switch (direction) {
case ENGLISH_FRENCH:
printf("English");
break;
case FRENCH_ENGLISH:
printf("French");
break;
}
printf(": ");
i = 0;
scanf("%c", &c);
while (c != '\n') {
user_word[i] = c;
i++;
if (i >= BUFFER_LENGTH) {
i = BUFFER_LENGTH-1;
}
scanf("%c", &c);
}
user_word[i] = '\0';
switch (direction) {
case ENGLISH_FRENCH:
printf(" The corresponding word is: ");
/* TODO */
break;
case FRENCH_ENGLISH:
printf(" The corresponding word is: ");
/* TODO */
break;
}
return 0;
}In: Computer Science
C PROGRAM STRING AND FILE PROCESSING LEAVE COMMENTS! I WILL LEAVE POSITIVE REVIEW! THANK YOU :)
I need a program that
1) Count all words in a file. A word is any sequence of characters delimited by white space or the end of a sentence, whether or not it is an actual English word.
2)Count all syllables in each word. To make this simple, use the following rules:
•Each group of adjacent vowels (a, e, i, o, u, y) counts as one syllable (for example, the “ea” in “real” counts as one syllable, but the “e..a” in “regal” count as two syllables). However, an “e” at the end of a word does not count as a syllable. Each word has at least one syllable even if the previous rules give a count of zero.
3) Count all sentences in the file. A sentence is a group of words terminated by a period, colon, semicolon, question mark, or exclamation mark. Multiples of each of these characters should be treated as the end of a single sentence. For example, “Fred says so!!!” is one sentence.
4) Calculates the Flesh index which is is computed by: index= 206.835 – 84.6 * ( #syllables / #words) – 1.015 * (#words / #sentences) rounded to the nearest integer (use the round function rather than ceiling or floor)
Input
Your program will read the text to be analyzed from a file. The filename is to be given as a command line parameter to the program. You will name the program fleschIndex.c and will execute the code on a file by doing the following:
./fleschIndex
For example, if you have a file with an essay and the file was named example.txt then you would do the following to find the Flesch index:
./fleschIndex example.txt
Output
The output(to stdout) from your program will be the following:
1. The Flesch/legibility index that you have computed
2. The number of syllables in the input
3. The number of words in the input
4. The number of sentences in the input
It will have the following format (and must match exactly):
OUTPUT TO CONSOLE
Flesch Index = 87
Syllable Count = 10238
Word Count = 2032
Sentence Count = 1
In: Computer Science
IPE:What lessons does mercantilism hold for the 21st Century? Word Limit: 1000
In: Economics
What are the economic impacts of coronavirus?Please essay type 500-600 word
In: Economics
Please write a pep/9 assembly code that checks if a word or number is a palindrome
In: Computer Science
Differentiate HOME CARE from HOSPICE CARE Write a 350-word paper
In: Nursing
Please answer in microsoft word
analyze the the pharmaceutical industry’s choice of the product to produce
In: Economics
Please answer in microsoft word
For the Country Bolivia analyze there international trade policies
In: Economics