Sample Input: The moon shines bright in the midnight sky, As I lay here and wonder why, The stars twinkle, one by one, A peaceful sight, when day is done. The night is calm, and all is still, A moment to rest, and just be still, With the gentle breeze, and the rustling trees, I drift away, to a place of peace. Sample Output: [1] [1] The moon shines bright in the midnight sky, [1] [2] As I lay here and wonder why, [1] [3] The stars twinkle, one by one, [1] [4] A peaceful sight, when day is done. [2] [1] The night is calm, and all is still, [2] [2] A moment to rest, and just be still, [2] [3] With the gentle breeze, and the rustling trees, [2] [4] I drift away, to a place of peace.
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
![Question 2: File read write
You have been tasked with creating a class
called Practical12, which can read in a text file
named rhyme.txt containing a welcoming
rhyme to second-year computer science
students. Once the file is read, the class should
then write a new file called rhyme2.txt in the
following format:
[Verse number] [Line number] line from file.
To accomplish this, you will need to use file
input and output operations within the class.
Instructions:
1. Create a class Practical12 to read in
rhyme.txt
2. Loop or do something to keep track
of each line and verse
3.
Create a new text file Rhyme2.txt
4. Write each new line in the format
displayed below to the file
Rhyme2.txt:
[Verse number] [Line number] line from file
5. Write your full name and student
number at the end or beginning of
the text file.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F7e5db40a-5cf4-4e46-9879-689d98d5649e%2Ff24e4957-412a-47ce-ae8f-9b7ff9b5749c%2Fdg2ag1q_processed.jpeg&w=3840&q=75)
![Sample Input:
The moon shines bright in the midnight
sky,
As I lay here and wonder why,
The stars twinkle, one by one,
A peaceful sight, when day is done.
The night is calm, and all is still,
A moment to rest, and just be still,
With the gentle breeze, and the rustling
trees,
I drift away, to a place of peace.
Sample Output:
[1]
[1] The moon shines bright in the
midnight sky,
[1]
[2] As I lay here and wonder why,
[1] [3] The stars twinkle, one by one,
[1] [4] A peaceful sight, when day is
done.
[2] [1] The night is calm, and all is
still,
[2] [2] A moment to rest, and just be
still,
[2] [3] With the gentle breeze, and
the rustling trees,
[2] [4] I drift away, to a place of
peace.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F7e5db40a-5cf4-4e46-9879-689d98d5649e%2Ff24e4957-412a-47ce-ae8f-9b7ff9b5749c%2Fo8bhgi_processed.jpeg&w=3840&q=75)

Step by step
Solved in 4 steps with 4 images









