Coding Practice¶
Write a program that prompts a user for the name of an input file
and for an integer n
. Then open the file and output the first
n
lines of the file with each line reversed. For example,
if you read in the line “hello world” you should print out
“dlrow olleh” to the terminal. Include proper file error checking.
Select the Parsonsprob tab for hints for the construction of the code.
Write a program that prompts a user for the name of an input file
and for an integer n
. Then open the file and output the first
n
lines of the file with each line reversed. For example,
if you read in the line “hello world” you should print out
“dlrow olleh” to the terminal. Include proper file error checking.
Use the lines to construct the code, then go back to complete the Activecode tab.
Below are the contents of the input file.
We choose to go to the Moon. We choose to go to the Moon...
We choose to go to the Moon in this decade and do the other things,
not because they are easy, but because they are hard; because that goal
will serve to organize and measure the best of our energies and skills,
because that challenge is one that we are willing to accept, one we are
unwilling to postpone, and one we intend to win, and the others, too.
Write a program that prompts a user for an integer n
and print the first n
powers of 2 to an output file called powers.txt
. Include proper file error checking.
To simulate what your output file would look like, the contents of your output file
will be displayed on the terminal. Select the Parsonsprob tab for hints for the construction of the code.
Write a program that prompts a user for an integer n
and print the first n
powers of 2 to an output file called powers.txt
. Include proper file error checking.
To simulate what your output file would look like, the contents of your output file
will be displayed on the terminal. Use the lines to construct the code, then go back
to complete the Activecode tab.
Write a program that takes an input file called “dream.txt” and outputs the number of times the string “you” appears in the file to the terminal. Include proper file error checking. Select the Parsonsprob tab for hints for the construction of the code.
Write a program that takes an input file called “dream.txt” and outputs the number of times the string “you” appears in the file to the terminal. Include proper file error checking. Use the lines to construct the code, then go back to complete the Activecode tab.
Below are the contents of the input file.
Have you ever had a dream that you,
um, you had, your, you- you could,
you’ll do, you- you wants, you, you
could do so, you- you’ll do, you could-
you, you want, you want them to do you
so much you could do anything?
Write a program that takes an input file called “shrimp.txt” and outputs the quote with “shrimp” replaced by a word that the user inputs to the terminal. Include proper file error checking. Select the Parsonsprob tab for hints for the construction of the code.
Write a program that takes an input file called “shrimp.txt” and outputs the quote with “shrimp” replaced by a word that the user inputs to the terminal. Include proper file error checking. Use the lines to construct the code, then go back to complete the Activecode tab.
Below are the contents of the input file.
There's pineapple shrimp, lemon shrimp, coconut shrimp,
pepper shrimp, shrimp soup, shrimp stew, shrimp salad,
shrimp and potatoes, shrimp burger, shrimp sandwich.
That- that's about it.
Write a program that computes the product of two matrices. Take a look at the example below. Two find the product of two matrices, take the ith row from the first matrix and the jth column from the second matrix, find the summation of the product of each component, and that’s the value that goes into the (i, j) location of the new matrix. The product of an mxn and an nxp matrix is an mxp matrix. Select the Parsonsprob tab for hints for the construction of the code.
Write a program that computes the product of two matrices. Take a look at the example below. To find the product of two matrices, take the ith row from the first matrix and the jth column from the second matrix, find the summation of the product of each component, and that’s the value that goes into the (i, j) location of the new matrix. The product of an mxn and an nxp matrix is an mxp matrix. Use the lines to construct the code, then go back to complete the Activecode tab.