Using an editor, like Notepad++ or VIM open a file called:
loop1.py
In the editor enter the code
shown below. Do NOT omit the indentation--in
Python, indentation is required to indicate
what code is inside a loop:Save the file and run in a Cygwin terminal.
As you can see below, the code loops through all the listed computer brands
python3 loop1.py
.
Python Loops: Numerical Values
Using an editor, like Notepad++ or VIM open a file called:In the editor enter the code shown below. Do NOT omit the indentation--in Python, indentation is required to indicate what code is inside a loop:
loop2.py
Save the file and Execute this command to run the script:
As you can see, the code loops through all the numbers and evaluated the summing equation all 10 in the range from 0 to 9
python3 loop2.py
:
Using an editor, like Notepad++ or VIM open a file called:
In the editor enter the code shown below. Do NOT omit the indentation--in Python, indentation is required to indicate what code is inside a loop:
loop3.py
Save the file and Execute this command to run the script:
As you can see, the code loops through all the numbers and evaluated the summing equation all 6 number [1,10,20,30,40,50]:
python3 loop3.py
No comments:
Post a Comment