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>
The four levels of organization incorporate official chiefs, program executives, improvement chiefs, and give essayists. The meaning of business organization is a program of study offered at colleges and schools that attention on business hypothesis, practices, and administration. A case of business organization is a class on the standards of bookkeeping.
Answer:
Following are the program in the Python Programming Language.
#set list type variable and initialize the elements
myPizza = ['Margarita', 'Capsicum and onion', 'Chicken']
#set variable and initialize the elements
frndPizzas = myPizza[:]
#append value in list variable
myPizza.append('Corn')
#append value in list variable
frndPizzas.append('paperica')
#print message
print("My pizzas are:")
#set the for loop and print elements of 1st list
for pizza in myPizza:
print(pizza)
#print message
print("\nFriend's pizzas are:")
#set the for loop and print elements of 2st list
for frndsPizza in frndPizzas:
print(frndsPizza)
<u>Output</u>:
My pizzas are:
Margarita
Capsicum and onion
Chicken Corn
Friend's pizzas are:
Margarita Capsicum and onion Chicken paperica
Explanation:
<u>Following are the description of the program</u>:
- Set a list data type variable that is 'myPizza' and initializes elements in it.
- Set another list data type variable that is 'frndPizzas' and initializes elements in it.
- Append one-one element in both of the list data type variables.
- Set the for loops to print the elements of both list data type variables.
Answer:
#include <iostream>
using namespace std;
int main()
{
cout << "N\t10*N\t100*N\t1000*N" << endl;
int x=1;
while(x<=5){
cout << x <<"\t"<< x*10 <<"\t"<<x*100 <<"\t"<< x*1000 << endl;
x++;
}
return 0;
}
Explanation:
Print the header, N 10*N 100*N 1000*N, using \t
Initialize the x as 1. It will be used to control the while loop
Create a while loop that iterates while x is smaller than or equal to 5
Inside the loop, print the required values. After printing, increment the value of x by 1