1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kap26 [50]
2 years ago
12

How to do the for loop in python

Computers and Technology
1 answer:
shusha [124]2 years ago
8 0

Answer:

To loop through a set of code a specified number of times, we can use the range() function, The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and ends at a specified number.

Explanation:

hope this helps

You might be interested in
Write C++ code to open a document with the name Hello.txt, place the message "Hello, World!" in the document, and exit the docum
gavmur [86]

Answer:

#include<iostream>

#include<fstream>

using namespace std;

int main()

{

ofstream out;

out.open("Hello.txt");

out << "Hello, World!"<< endl;

out.close();

ifstream in;

in.open("Hello.txt");

while(in.good()){

   string line;

   in >> line;

   cout << line << endl;

   

}

in.close();

return 0;

}

Explanation:

Step 1:

Add all your preprocessor files directive,  #include is known as the preprocessor  is used to load files needed to run the code.

#include<iostream>: it provides basic input and output services for C++ programs.

#include<fstream>:used to open a file for writing and reading

using namespace std; means you'll be using namespace std means that you are going to use classes or functions (if any) from "std" namespace

Step 2:

ofstream out; <em>his  is  used  to  create  files  and   write data to the file</em>

out.open("Hello.txt"); <em>  a new file "HELLO.txt" has been created</em>

out << "Hello, World!"<< endl;  "<em>Hello World!" has now been writen to the file</em>

out.close(); <em>The file is now closed</em>

<em>This second step opens a new file and writes hello world to the file then closes it.</em>

Step 3:

<em>ifstream in; ifstream in c++ is a stream class which stands for input file stream a  is used for reading data from file.</em>

in.open("Hello.txt"); <em>Reopens the file without recreating it. This is a very important step because if not done properly, you might discard the file you previously created and recreate it.</em>

while(in.good()){

<em> in.good() is true if the previous read operation succeeded without EOF being encountered</em>

   string line; <em>It declares a string variable line</em>

   in >> line; <em>reads the data into the line variable</em>

   cout << line << endl; <em>Prints out the line</em>

<em>reopens the file and read the message into a string variable "line".  prints out line then exits out of the file.</em>

5 0
3 years ago
__________ is a term used to indicate any unwanted event that takes place outside normal daily security operations. This type of
Delvig [45]
The answer is “a security event”
6 0
3 years ago
You must lower your high beams when within how many feet of an approaching vehicle?
drek231 [11]

2000 feet of any vehicle

7 0
3 years ago
Please please help I don’t understand this
garik1379 [7]

Answer:

It is this because yass

Explanation:

And yes

6 0
2 years ago
Read 2 more answers
Mmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Serga [27]

Answer:

al-Khwarizmi

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • An element in a web page that connects to a different location in the same page or a different page is a _____.
    8·1 answer
  • Enlist the various data analysis methods for study of Infrasonic waves, Seismic waves, Earthquake prone areas and how AI can be
    15·1 answer
  • Which statement about creating folders is TRUE?
    15·2 answers
  • There will be 10 numbers stored contiguously in the computer at location x 7000 . Write a complete LC-3 program, starting at loc
    14·2 answers
  • An IP address in the form 197.169.100.1 is called a(n) ________. dotted quad encryption key random number sequential access numb
    7·1 answer
  • In which circumstances would the view side by side feature be useful or helpful.
    15·2 answers
  • Three common risk factors for young drivers and how you plan to minimize these factors.
    13·1 answer
  • Enhancement of job satisfaction and productivity are key characteristics of which theoretical perspective of work design? ​
    6·1 answer
  • Choose the type of collection described.
    9·1 answer
  • A _ shows the end of a page . ​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!