Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Input-loop/Python/input-loop-1.py
Normal file
3
Task/Input-loop/Python/input-loop-1.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
while(True):
|
||||
x = input("What is your age? ")
|
||||
print(x)
|
||||
6
Task/Input-loop/Python/input-loop-2.py
Normal file
6
Task/Input-loop/Python/input-loop-2.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
my_file = open(filename, 'r')
|
||||
try:
|
||||
for line in my_file:
|
||||
pass # process line, includes newline
|
||||
finally:
|
||||
my_file.close()
|
||||
5
Task/Input-loop/Python/input-loop-3.py
Normal file
5
Task/Input-loop/Python/input-loop-3.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#from __future__ import with_statement # is not needed in Python 3.6
|
||||
|
||||
with open(filename, 'r') as f:
|
||||
for line in f:
|
||||
pass # process line, includes newline
|
||||
2
Task/Input-loop/Python/input-loop-4.py
Normal file
2
Task/Input-loop/Python/input-loop-4.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
line = my_file.readline() # returns a line from the file
|
||||
lines = my_file.readlines() # returns a list of the rest of the lines from the file
|
||||
3
Task/Input-loop/Python/input-loop-5.py
Normal file
3
Task/Input-loop/Python/input-loop-5.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import fileinput
|
||||
for line in fileinput.input():
|
||||
pass # process line, includes newline
|
||||
Loading…
Add table
Add a link
Reference in a new issue