Answer:
The solution code is written in Python 3 as below:
- outfile = open("greeting.txt", "w")
- outfile.write("Hello World")
- outfile.close()
Explanation:
To create a simple text file in Python, we can use Python built-in function, <em>open()</em>. There are two parameters needed for the open() function,
- the file name and
- a single keyword "w". "w" denote "write". This keyword will tell our program to create a file if the file doesn't exist.
The statement <em>open("greeting.txt", "w")</em> will create a text file named "<em>greeting.txt</em>" (Line 1)
To fill up the content in the greeting.txt, we use <em>write()</em> method. Just include the content string as the argument of the <em>write()</em> method. (Line 2)
At last, we use <em>close() </em>method to close the opened file,<em> outfile</em>. This will release the system resource from the<em> outfile.</em>
Answer:
n=5
Explanation:
if n= 5
i. n/5=5/5=1 so it divides completely the remainder is 0
ii. 97 - 6(5) = 97 - 30 = 67, 67 is a prime number.
I don’t have an explanation for why it is called this, because really the name of it is in its definition. The two words this sentence describes are cybercrime and computer crime. They are both the same thing.
Answer:
public String toString() {
return "#(" + red + "," + green + "," + blue + ")";
}
Explanation:
The code:
public String toString() {
return "#(" + red + "," + green + "," + blue + ")";
}
Is a tostring java code, and it is so easy to write one, as compare to other programming languages
Writing a tostring method returns a strinb representation of an object in Java. Normally, the toString method returns the name of the object’s class plus its hash code.
This code creates a new colour object; then the result of its toString method is printed to the console.
Tostring method can be override. The default implementation of toString isn’t very useful in most situations. So, one can just override it.